Jump to content


Photo

Strip all the numeric characters from a variabele


  • Please log in to reply
3 replies to this topic

#1 Mortier

Mortier
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 30 April 2006 - 10:29 AM

Hello

The topic title says it already, is there an way I can strip off all the numeric charcaters?
I can't find it.

So that : 'blabla78';

would become : 'blabla';

Thanks in advance!



#2 OOP

OOP
  • Members
  • PipPipPip
  • Advanced Member
  • 149 posts
  • LocationSaudi Arabia

Posted 30 April 2006 - 11:24 AM

I think it is better to user regular expression to prevent using any number from the very beginning instead of allowing numric value then filtering it.

thanks
<?php echo'The man who makes no mistakes does not usually make anything'; ?>

#3 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,025 posts

Posted 01 May 2006 - 11:45 AM

try
$str = 'blabla78';
$str = str_replace(range(0,9), '', $str);
echo $str;

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#4 Mortier

Mortier
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 01 May 2006 - 01:46 PM

Thanks, it works!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users