I have a list of 70 words. This list is used to check user input. The user input is a text, which has on average 30-100 words. If one of the words from my list is in the text then the user text is removed, otherwise it is allowed. In most cases it will be allowed, so it will loop through all words.
To check whether the words are in the user text I use:
$susWords = SuspiciousWord::where('checked', true)->get();
$foundSusWord = false;
foreach ($susWords as $word) {
if (preg_match_all("/" . $word->word . "/i", $user->flirttext)) {
$foundSusWord = true;
break;
}
}
I am not an expert when it comes to regex and performance. Could performance be an issue here?