Created
March 13, 2012 03:32
-
-
Save Streek/2026548 to your computer and use it in GitHub Desktop.
Phone Number Auto-Formatting
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
<?php | |
function phone_number($sPhone){ | |
$sPhone = ereg_replace("[^0-9]",'',$sPhone); | |
if(strlen($sPhone) != 10) return(False); | |
$sArea = substr($sPhone,0,3); | |
$sPrefix = substr($sPhone,3,3); | |
$sNumber = substr($sPhone,6,4); | |
$sPhone = "(".$sArea.")".$sPrefix."-".$sNumber; | |
return($sPhone); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment