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. 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 ); 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! Link to comment https://forums.phpfreaks.com/topic/266929-removing-only-letters/#findComment-1368493 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.