Hi SeenGee,
UK landline and mobile phone numbers are ten characters long without country code, leading zeros, commas and other garb.
The first four digits after the country code and leading zero are the network or geographic code, the six digits after that are the terminating number or DDI.
This might help:
// get rid of the crap: leading zeros, uk country code, brackets and hypens
$number= ereg_replace("^0","",$number);
$number= ereg_replace("^44","",$number);
$number= ereg_replace("\(","",$number);
$number= ereg_replace("\)","",$number);
$number= ereg_replace("-","",$number);
// check it is a valid number of the right length
if((preg_match("/[^0-9\(\)\(\)\. ]/", $number)) or (strlen($number)!="10")){
echo "Bad number";
}else{
// number is okay
// extract the area or network code
$code = substr("$number", 0, 4);
// extract the destimation number
$ddi = substr("$number", 4, 6);
// package it back together and bingo
$number = "44 (0) $code $ddi";
echo "$number";
}
If you wanted to take it a step further you can download files of numbers from Oftel which tell you more about the network / area code, like what mobile network or town......
http://www.oftel.gov.uk/ind_info/numbering/download.htm
Tis Crown Copyright so use it mischeviously and they'll throw you in the tower of London..... and no you can't blame me 😉
Hope it helps