Filter badwords

Here’s a way to filter words that are foul. Here we have a table of blocked words loaded in the DB, then the script test every “word” inside your string versus the list of banned words in our DB. This even gives you what specific “banned words” is being filtered. Enjoy the code.

public function filter_words($string) {

$banned_words = $this->get_bad_words();
$badword = $this->found_bad_word;

for($i=0; $ifound_bad_word = $banned_words[$i];
}
}

if (!empty($this->found_bad_word)) {
return true;
} else {
return false;
}

}

Advertisement

About kaixersoft

Proud to be Pinoy. Batangueno in nature. Love to see and write computer codes. View all posts by kaixersoft

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.