Page 1 of 1

only numbers

Posted: Thu Jan 26, 2006 5:02 am
by shiznatix
ok so I was looking around and could not find it. I need to preg_replace everything but numbers 0-9 so the string can contain as many numbers as they want but no other characters but numbers. I know its like '/\d^[a-z]/i' or somthing but that would not cover the other characters out there. how do I do this?

Posted: Thu Jan 26, 2006 5:19 am
by JayBird
what are you trying to do?

Just check that all the characters in a string are numbers?

Or removing any non-numeric characters?

Posted: Thu Jan 26, 2006 5:22 am
by shiznatix
removing all non-numeric numbers but i want to check if those strings where changed in the first place so i guess it will be a combo of preg_match and preg_replace

Posted: Thu Jan 26, 2006 5:44 am
by raghavan20

Code: Select all

preg_replace("/[^0-9]/", "", $search_string);

Posted: Thu Jan 26, 2006 6:11 am
by shiznatix
haha thanks, I was thinking to hard on somthing so simple.