Can the in_array
function compare objects?
For example, I have an array of objects and I want to add them distinctly to another array. Is it possible t
You can use strict comparison:
in_array($object, $array, TRUE);
Usage example:
$a = new stdClass();
$a->x = 42;
$b = new stdClass();
$b->y = 42;
$c = new stdClass();
$c->x = 42;
$array = array($a,$b);
echo in_array($a, $array, true); // 1
echo in_array($b, $array, true); // 1
echo in_array($c, $array, true); //