Re: Question on explode and join.

From: Date: Wed, 13 Sep 2006 17:09:04 +0000
Subject: Re: Question on explode and join.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-241741@lists.php.net to get a copy of this message
Beauford wrote:
I have a form which I want to check for inappropriate words before it is posted. I have used explode to put the string into an array using a space as the delimiter and then I check it against another array that contains the inappropriate words. I then replace the inappropriate words with *'s and join the array back into a string. This works perfectly except for one thing. If the word in the string has a any kind of punctuation after it (period, comma) it won't be matched. So if moron is an inappropriate word then "you are a moron" works, but "you are a moron." won't. Any ideas?
$filtered = str_ireplace(array('naughty','words'),array('*','*'),$_POST['input_string']); jon

« previous php.general (#241741) next »