This question has been asked before about strings, however *none of the questions I've reviewed (not mods do not remove or tell us this is a duplicate please) actually answer my question.
I have a landing page with a simple signup via email box. Recently people have been abusing it by entering foreign characters such as *, #, $, % and also using profanity on purpose (you can always tell). I have an array of banned characters and words I'm using as follows
$banned = array("f**k", "f******", "blah", "*", "#", "$", "%");
I can tell for sure someone has been purposely trying again and again to get through it because I've missed out some characters and suddenly a bunch of addresses have been entered making no sense at all. I need to know how to use a For loop to go through and find if the following contains any of the banned words in the array
$email = $_POST['email'];
I have tried using
$arrlen = count($banned);
for($i=0; $i < $arrlen; $i++) {
if(stripos($email, $banned[$i] !== false) {
echo 'Banned word or character!';
}
else {
echo 'Email signed up!';
}
}
This did not work at all! I tried an old function is_str_contain but the error of function does not exist came back.
I tried the normal strpos as well, still no joy.