This question on \'How to tell if a PHP array is empty\' had me thinking of this question
Is there a reason that count
should be used instead of e
Since a variable parsed as negative would return int(1)
with count()
I prefer ($array === [] || !$array)
to test for an empty array.
Yes, we should expect an empty array, but we shouldn't expect a good implementation on functions without enforced return types.
Examples with count()
var_dump(count(0));
> int(1)
var_dump(count(false));
> int(1)