Page 1 of 1

how can i clean chrs that are not numbers and live only numb

Posted: Tue Dec 16, 2003 3:46 am
by pelegk2
i have this string :
"5d2e1fe"
and i want to get only : "521"
how can i do it?
thanks in advance
peleg

Posted: Tue Dec 16, 2003 3:54 am
by twigletmac
You could use [php_man]preg_replace[/php_man]():

Code: Select all

$text_and_numbers = '5d2e1fe';
$just_numbers = preg_replace('/[^0-9]/', '', $text_and_numbers);

echo $just_numbers;
Mac

Posted: Tue Dec 16, 2003 3:56 am
by twigletmac
P.S. Is this directly related to this:
viewtopic.php?t=15665

Mac

Posted: Tue Dec 16, 2003 4:19 am
by pelegk2
yepppp