3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $arr = array(); $arr['i1'] = 99; $arr['i2'] = 89; function cmp($a, $b) { global $arr; if ($arr[$a] > $arr[$b]) { return 1; } if ($arr[$a] < $arr[$b]) { return -1; } return 0; } if (uksort($arr, 'cmp')) { echo "success"; } else { echo "failure"; } print_r($arr);
Output for 4.3.0 - 5.2.11, 5.3.0 - 5.3.1, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
successArray ( [i2] => 89 [i1] => 99 )
Output for 5.2.12 - 5.2.17, 5.3.2 - 5.6.28
Warning: uksort(): Array was modified by the user comparison function in /in/AhIPN on line 17 failureArray ( [i1] => 99 [i2] => 89 )