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?! Link to comment https://forums.phpfreaks.com/topic/104751-solved-stripping-out-slashes-dashes-and-parens/ 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. Link to comment https://forums.phpfreaks.com/topic/104751-solved-stripping-out-slashes-dashes-and-parens/#findComment-536220 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? Link to comment https://forums.phpfreaks.com/topic/104751-solved-stripping-out-slashes-dashes-and-parens/#findComment-536221 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/ Link to comment https://forums.phpfreaks.com/topic/104751-solved-stripping-out-slashes-dashes-and-parens/#findComment-536222 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); Link to comment https://forums.phpfreaks.com/topic/104751-solved-stripping-out-slashes-dashes-and-parens/#findComment-536223 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.