How do you iterate through an array to eventually use it in an "if" structure that validates user input to equal one array value exclusively?
<?
$array[] = "valueone";
$array[] = "valuetwo";
// count the array and subtract one because array indexing starts at zero
$countem = count($array) - 1;
for ($i=0;$i<countem;$i++) {
$allarrays = ereg($array[$i], $post_user_input);
}
if ( !$allarrays) {
echo "Error. Your input does not match.";
}
else {
echo "You input matches.";
}
?>
With this script, only the first one is allowed:
if the user input is "valueone", it will match. However, "valuetwo" will not match. What is wrong with this script😕