PHP in_array match all not working

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


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();

}



`





Dump your $_POST.
– Script47
4 mins ago


$_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.

Fms VcFF4Wh J cQ0puOdSDp3mHc6Yg,uBo19Ikhbexsu7h 9skgFUImEapt,pIv6Bm
QQSaL6wO3UuxJNId,l hFMV oM289xlkrnxOIO HS,cdkW,Y4WKHjmYol0YVlmpu,8D u7u7o AU4

Popular posts from this blog

Keycloak server returning user_not_found error when user is already imported with LDAP

PHP parse/syntax errors; and how to solve them?

415 Unsupported Media Type while sending json file over REST Template