dudejma Posted August 10, 2012 Share Posted August 10, 2012 I have read the PCRE page on PHP and I still don't understand. All I'm trying to do is simply remove the letters from this variable. I have a variable, for example "555tul,748den". I simply want to remove the letters, but keep the comma. Everywhere I've looked, all the examples remove the letters but remove the comma too. I need to keep the comma. Any suggestions? Much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/266929-removing-only-letters/ Share on other sites More sharing options...
Pikachu2000 Posted August 10, 2012 Share Posted August 10, 2012 str_replace can do that . . . $haystack = "555tul,748den"; $needles = array_merge( range('a', 'z'), range('A', 'Z') ); $new_str = str_replace( $needles, '', $haystack ); Quote Link to comment https://forums.phpfreaks.com/topic/266929-removing-only-letters/#findComment-1368489 Share on other sites More sharing options...
dudejma Posted August 10, 2012 Author Share Posted August 10, 2012 Every time I try to use str_replace, I always mess something up. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/266929-removing-only-letters/#findComment-1368493 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.