php - how to check if an array has value that === null without looping? -
http://php.net/manual/en/function.in-array.php - has issues since checks ==
. there clever oneliner here can ===
?
that return false if array empty, has 0 elements, or when array doesn't contain value null. true if array has @ least 1 === null
element.
in_array(null, $haystack, true);
if read the doc referenced, you'll see that function takes optional third parameter:
if third parameter strict set true in_array() function check types of needle in haystack.
here function signature, appears in doc:
bool in_array ( mixed $needle , array $haystack [, bool $strict = false ] ) searches haystack needle using loose comparison unless strict set.
Comments
Post a Comment