Date: 10/01/01
- Next message: Tom Churm: "[PHP] Re: Array Elements & While Loops"
- Previous message: °ü¸®À: "[PHP] PersonalDB.net ȸ¿øÀ¸·Î ÃÊ´ë¹ÞÀ¸¼½À´Ï´Ù"
- In reply to: Maxim Maletsky \(PHPBeginner.com\): "RE: [PHP] word filter"
- Next in thread: Richard Heyes: "RE: [PHP] word filter"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
and btw Maxim...I didn't write the $naught_words array in the first place...
"Maxim Maletsky )" <php-general <email protected>> wrote in message
news:014a01c14a54$05530640$4829abd4 <email protected>
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:php-general <email protected>]
Sent: lunedì 1 ottobre 2001 10.33
To: '_lallous'; php-general <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:elias_bachaalany <email protected>]
Sent: lunedì 1 ottobre 2001 11.15
To: php-general <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" <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>-- 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>
-- 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>
- Next message: Tom Churm: "[PHP] Re: Array Elements & While Loops"
- Previous message: °ü¸®À: "[PHP] PersonalDB.net ȸ¿øÀ¸·Î ÃÊ´ë¹ÞÀ¸¼½À´Ï´Ù"
- In reply to: Maxim Maletsky \(PHPBeginner.com\): "RE: [PHP] word filter"
- Next in thread: Richard Heyes: "RE: [PHP] word filter"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

