bri0987 Posted November 19, 2007 Share Posted November 19, 2007 How can I change these two numbers into phone numbers? 5551231234 9009876789 echo INTO: (555) 123-1234 (900) 987-6789 Thanks, BRI Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 19, 2007 Share Posted November 19, 2007 try the following $number = 5551231234; $number = preg_replace("/(\d{3})(\d{3})(\d{4})/","($1) $2-$3",$number); print $number; you can also achieve the same through substr Quote Link to comment Share on other sites More sharing options...
wsantos Posted November 19, 2007 Share Posted November 19, 2007 you can also achieve the same through substr That would be $phonenumber = "(" . substr($string,0,3) . ") " . substr($string,3,3) . "-" . substr($string,6,4); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.