I want a function or method in PHP that will detect swearwords in obscured text. Something that will check string like:
$string = "hey you swearword!" or
$string = "hey you swear#word!"
or maybe even
$string = "hey you sw3arw0rd!"
for "swearword" and will return true if it contains that bad swearword and false if it does not. I don't want people to use bad word on my site, please help!
Just a simple example to show the direction:
$stopwords = ['swearword'];
$test = ['swear#word','sw3arw0rd','goodword','swearw*rd','swe*rw*rd','swe*!**rd'];
foreach($test as $word){
foreach($stopwords as $stopword){
if(levenshtein($stopword,$word)<=2){
print "levenshtein: '$word' seems to mean $stopword<br/>";
continue 2;
}
}
if(strlen(preg_replace('#[a-zA-Z]+#','',$word))!==0){#special char found
print "preg_replace: '$word' seems to have illegal chars<br/>";
continue;
}
print "'$word' seems be NO stopword<br/>";
}