3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = new StdClass(); $b = new StdClass(); $array1 = array($a, $a, $b); $array2 = array($a, $b, $b); $count1 = array(); foreach ($array1 as $val) { $hash = spl_object_hash($val); if (! isset($count1[$hash])) { $count1[$hash] = 0; } $count1[$hash]++; } var_dump($count1);

preferences:
43.5 ms | 402 KiB | 5 Q