Re: [PHP] word filter From: _lallous (elias_bachaalany <email protected>)
Date: 10/01/01

 $naughty_words = array(
 'poop',
 'bum',
 'religion'
     );
if (eregi(join('|', $naughty_words), $text))
  echo "found bad words!";
else
  echo "text is clean!";

"Richard Heyes" <richard.heyes <email protected>> wrote in message
news:NEBBIDEMHHJJCANAAAKFAENCJFAA.richard.heyes <email protected>
>
> > 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
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe <email protected>
For additional commands, e-mail: php-general-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>