Lets say I have an array of bad words:
$badwords = array("one", "two", "three");
And random string:
$string = "some variable text";
How to create this cycle:
if (one or more items from the $badwords array is found in $string)
echo "sorry bad word found";
else
echo "string contains no bad words";
Example:
if $string = "one fine day" or "one fine day two of us did something"
, user should see sorry bad word found message.
If $string = "fine day"
, user should see string contains no bad words message.
As I know, you can't preg_match
from array. Any advices?