3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function cmp($a, $b) { $x = $GLOBALS['x']; $v1 = $x[$a]; $v2 = $x[$b]; if ($v1 < $v2) { return -1; } elseif ($v1 > $v2) { return 1; } else { // Would then sort by key, irrelevant here. } } $x = array(1 => 1, 2 => 3, 3 => 2); uksort($x, 'cmp'); var_dump($x); // PHP5 //array(3) { [1]=> int(1) [3]=> int(2) [2]=> int(3) } // PHP7 //array(3) { [3]=> int(2) [2]=> int(3) [1]=> int(1) }
Output for 5.3.21 - 5.6.28, 7.0.6 - 7.2.0
array(3) { [1]=> int(1) [3]=> int(2) [2]=> int(3) }
Output for 7.0.0 - 7.0.5
array(3) { [3]=> int(2) [2]=> int(3) [1]=> int(1) }