Does in_array()
do object comparison where it checks that all attributes are the same?
What if $obj1 === $obj2
, will it just do pointer comparison instead?
I'm using an ORM, so I'd rather loop over the objects testing if $obj1->getId()
is already in the array if it does object comparison. If not, in_array
is much more concise.
in_array()
does loose comparisons ($a == $b
) unless you passTRUE
to the third argument, in which case it does strict comparisons ($a === $b
).Semantically,
in_array($obj, $arr)
is identical to this:...and
in_array($obj, $arr, TRUE)
is identical to this:...and to quote the manual on what this actually checks: