and btw Maxim...I didn't write the $naught_words array in the first place...
Maxim Maletsky ) [EMAIL PROTECTED] wrote in message
news:014a01c14a54$05530640$4829abd4@tatiana...
Sorry, I meant since PHP 4 only, as it is when function in_array() was
introduced
Maxim Maletsky
www.PHPBeginner.com
-Original Message-
From: Maxim Maletsky (PHPBeginner.com)
[mailto:[EMAIL PROTECTED]]
Sent: lunedì 1 ottobre 2001 10.33
To: '_lallous'; [EMAIL PROTECTED]
Cc: 'Kristjan Kanarik'; 'Richard Heyes'
Subject: RE: [PHP] word filter
There's a better way to do this:
?
$naughty_words = array(
'poop',
'bum',
'religion'
);
echo in_array($text, $naughty_words) ? found bad words! : text is
clean!; ?
Since PHP though...
P.S: are you considering 'region' a naughty word, _lallous? Careful
there...
Maxim Maletsky
www.PHPBeginner.com
-Original Message-
From: _lallous [mailto:[EMAIL PROTECTED]]
Sent: lunedì 1 ottobre 2001 11.15
To: [EMAIL PROTECTED]
Subject: Re: [PHP] word filter
$naughty_words = array(
'poop',
'bum',
'religion'
);
if (eregi(join('|', $naughty_words), $text))
echo found bad words!;
else
echo text is clean!;
Richard Heyes [EMAIL PROTECTED] wrote in message
news:[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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]