I have an array containing only booleans:
$l = array(0=>true,2=>false,3=>true,4=>true,5=>true);
I want to achieve this pseudocode:
If at least one element of $l is false:
echo 'Can not do this';
else:
echo 'Can do this';
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming you have a misspelling and the correct form is
Then you only need to iterate over the array and fail on the first
falsevalue in the array. I will not give you the answer, since it is homework and the solution is very simple.Take a look at the
ifstatement in the PHP manual and also theforeachstatement. That’s really all you need to solve your problem.