Notice: I have changed to stripos() function.
There is no need to search in reverse direction in the string, like strripos()
This is a code that can be used to find if one text contains 'bad words'
from a list, an array, of such words.
Now the found word ( $fword ) will be displayed.
Or 'not found'.
$fword is set to empty string initially.
But only first found word is catched.
Say you have a string with both 'two' and 'three'.
Only will catch the word 'two'.
<?php
$string = "four";
$search = array('one', 'two' ,'three', 'four');
$fword = '';
foreach($search AS $word){
if(false !== stripos($string, $word)){
$fword = $word;
break;
}
}
if($fword){
echo $fword;
}else{
echo "not found";
}
?>