RE: [PHP] word filter
| From: | Richard Heyes | Date: | Sat, 29 Sep 2001 17:53:13 +0000 |
| Subject: | RE: [PHP] word filter | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-69304@lists.php.net to get a copy of this message | ||
> Looking for a function which checks the user input for unwanted (mostly
> rude) words. Those words should be defined first in array or so of
> course... should be case insensitive as well.
$text = 'This text contains a naughty word: Bum';
$naughty_words = array(
'poop',
'bum',
'religion'
);
function naughty_words($text, $naughty_words){
$text = strtolower($text);
foreach($naughty_words as $value){
if(strpos($text, strtolower($value)) !== FALSE)
return TRUE;
}
return FALSE;
}
echo naughty_words($text, $naughty_words) ? 'Found naughty words' : 'Text is
clean';
--
Richard Heyes
"I know not with what weapons World War III will be fought, but World War IV
will be fought with sticks and stones." - Albert Einstein