Created
May 28, 2014 16:50
-
-
Save arturoleon/63dc5de543fd01cb9616 to your computer and use it in GitHub Desktop.
Format an US telephone number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function formatPhone($phone){ | |
return preg_replace('~.*(\d{3})[^\d]*(\d{3})[^\d]*(\d{4})(.*).*~', '($1) $2-$3 $4', $phone). "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment