Page 1 of 1

using eregi

Posted: Mon Apr 18, 2005 5:27 am
by gurjit
Hi all,

I have a field in the database where i need to take out any alpha at the end of a string and just keep the numbers. so for example i have:

"123 4 56778 hello"

I want to takeout any alpha nd keep numbers, how can i do this and display "123 4 56778"

Try...

Posted: Mon Apr 18, 2005 6:27 am
by icarpenter
Give this a try!

Code: Select all

$string = "123 4 56778 hello";
$test=ereg_replace("[A-Z a-z]", "", $string);
echo"$test";

Posted: Mon Apr 18, 2005 8:00 am
by gurjit
worked well,

Thanks