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); 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);
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.

preferences:
186.97 ms | 1395 KiB | 61 Q