PHP in_array match all not working

Multi tool use


PHP in_array match all not working
I'm trying to check whether ALL $_POST variables contain one of two possible strings, but can't get it to work. It seems to be true even if just one $_POST variable contains one of the strings
Following code works for one string
if ($_POST['1'] !== 'Yes' &&
$_POST['2'] !== 'Yes' &&
$_POST['3'] !== 'Yes' &&
$_POST['4'] !== 'Yes' &&
$_POST['5'] !== 'Yes') {
function_call();
}
However this code doesn't work when checking for two
$value_arr = array('Yes','Maybe');
if ((!in_array($_POST['1'], $value_arr)) &&
(!in_array($_POST['2'], $value_arr)) &&
(!in_array($_POST['3'], $value_arr)) &&
(!in_array($_POST['4'], $value_arr)) &&
(!in_array($_POST['5'], $value_arr))) {
function_call();
}
`
$_POST
Then remove the
!
's– Lawrence Cherone
1 min ago
!
^^^^^ This, or change
&&
to ||
and move function to an else, but that would be ugly.– AbraCadaver
5 secs ago
&&
||
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Dump your
$_POST
.– Script47
4 mins ago