3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = ['val1', 'val2', 200, 179, 230, 234, 242]; $order = [230, 234, 242, 179, 100]; $keyedOrder = array_flip($order); // for efficiency usort($array, function($a, $b) use ($keyedOrder) { return [$keyedOrder[$a] ?? -1, $a] <=> [$keyedOrder[$b] ?? -1, $b]; }); var_export($array);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => 200, 1 => 'val1', 2 => 'val2', 3 => 230, 4 => 234, 5 => 242, 6 => 179, )

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