Entry
How can I remove unwanted characters from a string?
Jul 9th, 2003 13:07
Gerhardt, Nathan Wallace, matt, Sascha Schumann
Solution with str_replace (not tested):
---------------------------------------
$unwanted = Array('a','b','c');
$text = str_replace($unwanted,'',$text);
Solution with Regular Expression:
---------------------------------
You can use more than one argument to ereg_replace in the same line lie
so:
$message=ereg_replace("([^%)#&?])","",$message);
The PHP distribution contains a man page which discusses POSIX
style regular expressions. It is in php-3.0.x/regex/regex.7. To
read it, use
nroff -man php-3.0.x/regex/regex.7 | less
If you prefer Perl-style regular expressions, read on at
http://www.php.net/manual/ref.pcre.php3