I need to check if all values in an array equal the same thing.
For example:
$allValues = array(
'true',
'true',
'true',
);
If every value in the array equals 'true'
then I want to echo 'all true'
. If any value in the array equals 'false'
then I want to echo 'some false'
Any idea on how I can do this?
Why not just compare count after calling
array_unique()
?To check if all elements in an array are the same, should be as simple as:
This should work regardless of the type of values in the array.
You can compare min and max... not the fastest way ;p