I\'m new in PHP
I have an array like this
$suspiciousList = array(
array (\"word\" => \"badword1\", \"score\" => 400, \"type\" => 1),
array
As Jirka Helmich suggested you could remove whitespaces (and maybe other special chars) and then search the string to find words from your array.
public function searchForBadWords($strippedText) {
foreach($suspiciousList as $suspiciousPart) {
$count = substr_count($strippedText, $suspiciousPart['word']);
//you can use str_replace here or something, it depends what you want to achive
}
}
Problem is if you have words like blablabad wordblabla and you remove spaces to normal words could become bad words blablabadwordblabla
(know what I mean?) :D
Cheers
Edit: So Ahmad I see you just get words recognizing them by " " on the beginning/end(in shortcut). Maybe you should try to implement both methods, yours with single words and this above with substring searching. It depends also how much you care about performance. Maybe you should try do some reserches or sth to see how effective it is?:D