As you know, there is a common code to replace bad words:
$badwords = array('bad', 'very bad');
$string = str_replace($badwords, "***", $string)开发者_运维问答;
But what if spammers duplicate some of characters? like "baaad" or "veery bad".
You could implement a Levenshtein Distance algorithm using PHP's levenshtein. If the word only needs one edit to become a bad word, then it could be a possible spam word with duplicate characters.
精彩评论