3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $obj1 = new stdClass(); $obj1->attr = 'Rod'; $obj2 = new stdClass(); $obj2->attr = 'Jane'; $obj3 = new stdClass(); $obj3->attr = 'Freddy'; $array1 = array( $obj1, $obj2, $obj3 ); $array2 = array( $obj1, $obj3, $obj2 ); //$diff1 = array_diff($array1, $array2); $diff2 = array_udiff($array1, $array2, function($a,$b) { if ($a->attr == $b->attr) { return 0; } else { return -1; } }); $diff3 = array_udiff($array1, $array2, function($a,$b) { if ($a->attr == $b->attr) { return 0; } else { return 1; } }); $int = array_intersect($array1, $array2); //var_dump($diff1); var_dump($diff2); var_dump($diff3);
based on ej3Ue
Output for 7.1.0 - 7.2.0
Recoverable fatal error: Object of class stdClass could not be converted to string in /in/FFAer on line 41
Process exited with code 255.
Output for 5.3.19 - 7.0.20
Catchable fatal error: Object of class stdClass could not be converted to string in /in/FFAer on line 41
Process exited with code 255.