3v4l.org

run code in 300+ PHP versions simultaneously
<?php $numericPriorities = array_flip([5, 4, 65]); $numericOutlier = count($numericPriorities); $wordPriorities = array_flip(['first', 'second', 'third']); $wordOutlier = count($wordPriorities); $arr = ['third' => 321, 4 => 1, 'zero' => 'last of words', 7 => 'last of nums', 65 => 6, 'first' => 63, 5 => 88, 'second' => 0]; uksort( $arr, function($a, $b) use ($numericPriorities, $numericOutlier, $wordPriorities, $wordOutlier) { return !is_int($a) <=> !is_int($b) ?: (($numericPriorities[$a] ?? $numericOutlier) <=> ($numericPriorities[$b] ?? $numericOutlier)) ?: (($wordPriorities[$a] ?? $wordOutlier) <=> ($wordPriorities[$b] ?? $wordOutlier)); } ); var_export($arr);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 5 => 88, 4 => 1, 65 => 6, 7 => 'last of nums', 'first' => 63, 'second' => 0, 'third' => 321, 'zero' => 'last of words', )

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