PHP profanity filter implementation

Possible duplicate:
How do you implement a good profanity filter?

I have an iPhone application that passes a string through the URL of my php script, which then inserts into my database. I would like to write some php code that reads $ body for any predefined irregularity.

Right now, I only have the following code, but it is only looking for exact matches, and not if $ body contains, then .. the type of sequence. In addition, I need him to replace the oath with an empty "", deleting everything together.

if($body == "swear word") 
    return;
+3
source share
1 answer
$swears = array("shoot", "darn", "heck");

foreach ($swears as $bad_word)
    $body = str_replace($bad_word, " ", $body);

, Scunthorpe (, "heckler" "ler", "heck" ).

+2

Source: https://habr.com/ru/post/1764560/


All Articles