- Output for 5.3.0 - 5.3.28, 5.4.0 - 5.4.24
- Parse error: syntax error, unexpected '=' in /in/vFvXk on line 9
Process exited with code 255.
<?php
$a = new StdClass();
$b = new StdClass();
$array1 = array($a, $a, $b);
$array2 = array($a, $b, $b);
countHashes = function($array) {
$count = array();
foreach ($array as $val) {
$hash = spl_object_hash($val);
if (! isset($count[$hash])) {
$count[$hash] = 0;
}
$count[$hash]++;
return $count;
}
$count1 = countHashes($array1);
$count2 = countHashes($array2);
var_dump($count1);
var_dump($count2);