using eregi

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
gurjit
Forum Contributor
Posts: 314
Joined: Thu May 15, 2003 11:53 am
Location: UK

using eregi

Post 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"
User avatar
icarpenter
Forum Commoner
Posts: 84
Joined: Mon Mar 07, 2005 8:12 am
Location: Kent, England

Try...

Post by icarpenter »

Give this a try!

Code: Select all

$string = "123 4 56778 hello";
$test=ereg_replace("[A-Z a-z]", "", $string);
echo"$test";
User avatar
gurjit
Forum Contributor
Posts: 314
Joined: Thu May 15, 2003 11:53 am
Location: UK

Post by gurjit »

worked well,

Thanks
Post Reply