[solved] Remove non-numbers
Posted: Fri Sep 22, 2006 2:22 pm
This seems so easy, but it's not working. I'd like to remove any characters that aren't 0,1,2,3,4,5,6,7,8, or 9. This is what I've got so far:
That seems like it should work, but '888-5555' keeps getting output. I tried replacing [^0-9] with ^\d as well, but that didn't work either.
Any ideas?
Code: Select all
$phone_number="888-5555";
preg_replace('/[^0-9]/','',$phone_number);
echo $phone_number;Any ideas?