Jump to content

Language Filtering


random1

Recommended Posts

Part of my website needs to filter out offensive language from a string (message) in the site and replace swear words with *****.

 

I have one that works from a text file:

 

http://www.geekpedia.com/tutorial163_Foul-language-filter-in-PHP.html

 

but I need it to work for my MySQL database instead.

 

I have a lookup database table that contains the offensive words:

 

table: language_filter

fields: id, offensive_word

 

Anyone have any suggestions on how to get a MySQL language filter working?

Link to comment
https://forums.phpfreaks.com/topic/83797-language-filtering/
Share on other sites

  • 4 weeks later...

You might have to use 2 preg statements.

one to filter the words from the body of the subject. see preg_replace_callback

than use the callback function to test the individual words against a list of bad words, using preg_match.

if preg_match catches a bad word, it can return the [censored] tag or what have u, otherwise return the original word sent by preg_replace_callback.

 

thats if u want the flexibility of using regular expressions

Link to comment
https://forums.phpfreaks.com/topic/83797-language-filtering/#findComment-449636
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.