Drack Posted May 15, 2007 Share Posted May 15, 2007 I'm in need of a way to eliminate all non-numeric characters from a string. Something in PHP that would accomplish this in perl: $code =~ s/[^0123456789]//; This is for the ClanOCR database, by the way. Anyone have any ideas? I don't know how to call a substitution regex in PHP, just match patterns. Perhaps there's some way to loop over the characters in a string and remove any that don't match 0123456789? --Drack Quote Link to comment Share on other sites More sharing options...
Drack Posted May 16, 2007 Author Share Posted May 16, 2007 I found the solution: $code = preg_replace('/[^0123456789]/','',$code); 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.