Hi, first of all I would uppercase all the letters:
$postcode = "bh228sr";
$postcode = strtoupper($postcode);
then use this function:
function format_post_code($code)
{
for ($i = strlen($code)-1; $i > 0 ; --$i) {
if (preg_match('/^\d$/', $code[$i])) {
return substr($code,0, $i) . " " . substr($code,$i);
}
}
return false;
}
echo format_post_code($postcode
(Source of function: http://www.experts-exchang
Hope this helps
Main Topics
Browse All Topics





by: us111Posted on 2008-01-14 at 07:32:50ID: 20653636
http://lu.php.net/manual/e n/function .substr.ph p
Select allOpen in new window