Welcome to WebmasterWorld Guest from 54.227.83.19

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Strip out non-alpha numeric

     

rfontaine

12:24 pm on Jun 28, 2006 (gmt 0)

10+ Year Member



Hi,

I am looking for a php function that will efficiently strip from a phrase all characters that are not alpha or numeric:

keep only: a-z A-Z and 0-9

What might you recommend trying, other than the usual "RTFM"?

Thank you in advance

rfontaine

12:35 pm on Jun 28, 2006 (gmt 0)

10+ Year Member



oh, also spaces are allowed

adb64

1:11 pm on Jun 28, 2006 (gmt 0)

10+ Year Member



Do a preg_replace [nl2.php.net] of "/[^a-zA-Z0-9 ]/" with an empty string "".
Probably the pattern can be optimised, but this one should work for you.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month