croakingtoad Posted May 8, 2008 Share Posted May 8, 2008 I have a var named $DeveloperTelephone that is being pulled from a database and the string value could be formatted like-- 540-111-1111 (540) 111-1111 866-111-1111 or 828-111-1111 I need to first remove all the dashes and parents and then count the first 10 digits to make that the new value. So the third value above would become-- 8661111111 How would I accomplish that please and thanks?! Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 8, 2008 Share Posted May 8, 2008 $take = array("-", "(", ")", "/", "\\"); $new = str_replace($take, "", $text); Replac $text with your variable. Quote Link to comment Share on other sites More sharing options...
croakingtoad Posted May 8, 2008 Author Share Posted May 8, 2008 great, but how do I get it to only return the first 10 characters in $new? Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted May 8, 2008 Share Posted May 8, 2008 look here for some great tutorials http://www.tizag.com/phpT/ Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 8, 2008 Share Posted May 8, 2008 Oh. Here: $take = array("-", "(", ")", "/", "\\"); $new = substr(str_replace($take, "", $text), 0, 10); 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.