3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function hasort($arr) { $a = $b = array(); foreach($arr as $v => $k) $a[$k][] = $v; ksort($a); foreach($a as $v => $i) foreach($i as $k) $b[$k] = $v; return $b; } $a = array('a' => 10, 'z' => 10, 'c' => 10, 'b' => 11, 'd' => 10); $a = hasort($a); print_r($a); echo '<pre>'; echo json_encode($a); echo '</pre>';
based on fsQkS
Output for 5.2.0 - 7.2.0
Array ( [a] => 10 [z] => 10 [c] => 10 [d] => 10 [b] => 11 ) <pre>{"a":10,"z":10,"c":10,"d":10,"b":11}</pre>
Output for 5.0.0 - 5.1.6
Array ( [a] => 10 [z] => 10 [c] => 10 [d] => 10 [b] => 11 ) <pre> Fatal error: Call to undefined function json_encode() in /in/qsiNT on line 14
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Array ( [a] => 10 [z] => 10 [c] => 10 [d] => 10 [b] => 11 ) <pre> Fatal error: Call to undefined function: json_encode() in /in/qsiNT on line 14
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Array ( [a] => 10 [z] => 10 [c] => 10 [d] => 10 [b] => 11 ) <pre> Fatal error: Call to undefined function: json_encode() in /in/qsiNT on line 14
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Array ( [a] => 10 [z] => 10 [c] => 10 [d] => 10 [b] => 11 ) <pre> Fatal error: Call to undefined function: json_encode() in /in/qsiNT on line 14