Format Phone Number
16
Format a phone number with php.
// Format phone number
function formatPhoneNumber($strPhone)
{
$strPhone = ereg_replace("[^0-9]",'', $strPhone);
if (strlen($strPhone) != 10)
{
return $strPhone;
}
$strArea = substr($strPhone, 0, 3);
$strPrefix = substr($strPhone, 3, 3);
$strNumber = substr($strPhone, 6, 4);
$strPhone = "(".$strArea.") ".$strPrefix."-".$strNumber;
return ($strPhone);
}






--
Chris Gmyr
www.chrisgmyr.com
www.syracusecs.com
www.syracusebands.net
All i did here was add the code and place this line before it:
$Phone=$strPhone;
to move my phone number field to the codes variable. When I echo $strPhone I get nothing
One can only tell from the code, that this function is valid for 10 digit phone numbers consisting of 3 digit area code and that the rest of the number is separated into a 3 digit prefix and rest...
Nevertheless, this snippet allows for easy adaptation to ones needs.