I have an array in which I push true or false values. And I only want to execute the next function if the array is completely true or completely. But because they are not strings, I can not check it with in_array(...)
.
Does anybody know how I can check if an array is completely true or completely?
Greetings and Thank You! :D
First, check if all the array have same value
Then check if it's TRUE or false.
if(count(array_count_values($array))===1){
if($array[0]){
// Completely TRUE;
}else{
// Completely FALSE;
}
}
$res = array_unique($array);
if(count($res) === 1 && $res[0]) {
// your code
}