3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = Array ( '3' => 10, '2' => 2, '5' => 'Nakiya', ); /** * Sort an array by key. */ function sortbyKeys($array, $direction = 'ASC') { $direction = (strtolower($direction) === 'desc') ? SORT_DESC : SORT_ASC; if ($direction === SORT_ASC) { ksort($array); } else { krsort($array); } return $array; } var_dump(sortbyKeys($array));
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { [2]=> int(2) [3]=> int(10) [5]=> string(6) "Nakiya" }

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:
80.96 ms | 405 KiB | 5 Q