Apr 2, 2005 #1 MSRez Programmer Dec 22, 2004 57 EU Is there any easy way to remove ALL non-alphanumeric characters in a string regardless of what they are? I couldn't find a function that does this which is quite surprising.
Is there any easy way to remove ALL non-alphanumeric characters in a string regardless of what they are? I couldn't find a function that does this which is quite surprising.
Apr 2, 2005 Thread starter #2 MSRez Programmer Dec 22, 2004 57 EU Ok, turns out there isn't already a function for it but it's simple anyway. Code: $string = preg_replace ("/[^a-z 0-9]/i",'',$string); Note: retains spaces in the string. Upvote 0 Downvote
Ok, turns out there isn't already a function for it but it's simple anyway. Code: $string = preg_replace ("/[^a-z 0-9]/i",'',$string); Note: retains spaces in the string.