Better Solution for Filtering Bad Words in PHP

I was searching for filtering Bad Words from my site……

I have visited so many links on google but…. 🙁

Here is my simple logic for filtering Bad Words from site or any search engine

First you have to make a txt file “badwords.txt” or you can search from google

Google Keyword: badwords + filetype:txt

Copy “badwords.txt” to your site and use below code for removing these words from site…..

<?php

// here file_get_contents() used for getting $badwords as a string

$badwords = strtolower(file_get_contents(“badwords.txt”));

// here $q is string used for checking against badwords

$pos = strpos($badwords, strtolower($q));

if ($pos !== false)
{

if(strstr($badwords, strtolower($q)) || strchr($badwords, strtolower($q)))
die(‘Website has blocked unwanted contents…. please try for legal keywords!’);
}

?>

Enjoy with svnlabs.com 🙂