I have a special list of spam words that are in an array. When a user submits a string text, I want to know if it contains these words. How do I do this? I wrote this code
$my_words = 'buy;sell;shop;purchase';
$array_words = explode(';' ,$my_words); //convert the list to an array
$input_text = 'we can sell your products'; //user will input this text
foreach($array_words as $word){
if(strpos($input_text ,$word) !== false) return 'You can't use from this text';
}
But if I have many special words, the foreach slows down the execution speed.