3v4l.org

run code in 300+ PHP versions simultaneously
<?php function uasort_key(&$arr, $func) { return uksort($arr, function($a,$b) use(&$arr,$func) { return $func($arr[$a], $arr[$b], $a, $b); }); } function sort_me($a, $b, $ka = 0, $kb = 0) { return ($a < $b ? -1 : ($a > $b ? 1 : ($ka < $kb ? -1 : ($ka > $kb ? 1 : 0)) )); } $test_array = array(4,6,2,1,7,5,1,34,1,0,4); $test_array_uasort = $test_array; $test_array_uasort_key = $test_array; uasort($test_array_uasort, 'sort_me'); uasort_key($test_array_uasort_key, 'sort_me'); echo 'Unsorted: '; print_r($test_array); echo 'uasort: '; print_r($test_array_uasort); echo 'uasort_key: '; print_r($test_array_uasort_key);
Output for git.master, git.master_jit, rfc.property-hooks
Unsorted: Array ( [0] => 4 [1] => 6 [2] => 2 [3] => 1 [4] => 7 [5] => 5 [6] => 1 [7] => 34 [8] => 1 [9] => 0 [10] => 4 ) uasort: Array ( [9] => 0 [3] => 1 [6] => 1 [8] => 1 [2] => 2 [0] => 4 [10] => 4 [5] => 5 [1] => 6 [4] => 7 [7] => 34 ) uasort_key: Array ( [9] => 0 [3] => 1 [6] => 1 [8] => 1 [2] => 2 [0] => 4 [10] => 4 [5] => 5 [1] => 6 [4] => 7 [7] => 34 )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
60.27 ms | 402 KiB | 8 Q