- var_dump: documentation ( source)
- array_unique: documentation ( source)
- iterator_to_array: documentation ( source)
<?php
$a = new stdClass;
$a->id = 2;
$b = new stdClass;
$b->id = 2;
$case1 = array_unique([$a, $b], SORT_REGULAR);
$storage = new SplObjectStorage();
$storage->attach($a);
$storage->attach($b);
$case2 = iterator_to_array($storage);
var_dump($case1, $case2);