PDA

View Full Version : PHP Regex Question


Drack
05-15-2007, 10:14 PM
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

Drack
05-16-2007, 05:06 PM
I found the solution:$code = preg_replace('/[^0123456789]/','',$code);