I need to format a phone number as one long string of numbers (US Phone Number format)
// I know there are tons more
$phones = array(
'1(800) 555-1212',
'1.800.555.1212',
'800.555.1212',
'1 800 555 1212',
'1.800 CALL NOW' // 1 800 225-5669
);
foreach($phones as $phone) {
echo "new format: ".(preg_replace("/[^0-9]/", "", $phone)."<br />\n";
}
Now this should return something like this:
8005551212 (with or without the 1)
but how do I map/convert the number with CALL NOW to:
18002255669
You could use
strtr().Or actually, I think: