I have an associative array in which I need to count the number of logical true values inside.
The end result is to create an if statement that returns true if there is only one true value in the array. It will need to return false if there is more than one true value in the array, or if there are no true values in the array.
I know that the best way would be to use count and in_array in one form or another. I'm not sure if this will work, just out of my head, but even if that happens, is this the best way?
$array(a->true,b->false,c->true) if (count(in_array(true,$array,true)) == 1) { return true } else { return false }
Thattechguy
source share