Re: dirty words
| From: | Kevin Waterson | Date: | Sat, 16 Oct 2004 15:12:08 +0000 |
| Subject: | Re: dirty words | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-199636@lists.php.net to get a copy of this message | ||
This one time, at band camp, Mag <genphp@yahoo.com> wrote:
> Hi,
> I am useing file_get_contents on a remote page then
> using stristr() to make sure there are no "bad words"
> and its a family site.
> Right now I am checking for just 3 bad words which
> means 3 stristr() function calls, but if the bad words
> increase then that would mean more calls....
$badwords = array('poo', 'bum', 'perl');
$goodString = str_replace($badwords, '***', file_get_contents($url);
echo $goodString;
If you are using php5 you can use str_ireplace() for a case insensitive
search
Kevin
---------
"Democracy is two wolves and a lamb voting on what to have for lunch.
Liberty is a well-armed lamb contesting the vote."