I have this code that must first process the entire word file in the array, and then check the string passed for any of these words in the file. if a match, then replace with *.
the file looks something like this:
wordalex wordjordan wordjohn ....
Unfortunately, the proposal I submitted is not filtered in the mod I expect. Nothing really happens to him. Could you familiarize yourself with the given code and help.
$comment = "the wordalex if this doesn't get caught!"; $filterWords = file('badwords.txt', FILE_IGNORE_NEW_LINES); //print_r($filterWords); $textToPrint = filterwords($comment,$filterWords ); echo $textToPrint; function filterwords($text, $filterArray){ $filterCount = sizeof($filterWords); for($i=0; $i<$filterCount; $i++){ $text = preg_replace('/\b'.$filterWords[$i].'\b/ie',"str_repeat('*',strlen('$0'))",$text); } return $text; }
therefore, in the original sentence there are bard words, but deleted for the purpose of publication.
thanks
source share