Array AND() ? Logical ANDing of all elements
I have an array and I want to find out if there is at least one false value in it. I was thinking of creating an array_and() function, that just performs a logical AND on all the elements. It would return true if all values are true, otherwise false. Am I over-engineering?
Why dont you just use
- in_array — Checks if a value exists in an array
// creates an array with 10 booleans having the value true. $array = array_fill(0, 10, TRUE); // checking if it contains a boolean false var_dump(in_array(FALSE, $array, TRUE)); // FALSE // adding a boolean with the value false to the array $array = FALSE; // checking if it contains a boolean false now var_dump(in_array(FALSE, $array, TRUE)); // TRUE