3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_alternate_multisort($array, ...$args) { foreach ($args as $i => $arg) { $sortParams[] = $i & 1 ? $arg : array_column($array, $arg); } $sortParams[] = &$array; array_multisort(...$sortParams); return $array; } $alliances = [ ['id' => 1, 'output' => '1', 'score' => 10], ['id' => 2, 'output' => '0', 'score' => 9], ['id' => 3, 'output' => '1', 'score' => 11], ['id' => 4, 'output' => '1', 'score' => 9], ['id' => 5, 'output' => '0', 'score' => 10], ]; $alliances = array_alternate_multisort($alliances, "output", SORT_DESC, "score", SORT_DESC); var_export($alliances);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'id' => 3, 'output' => '1', 'score' => 11, ), 1 => array ( 'id' => 1, 'output' => '1', 'score' => 10, ), 2 => array ( 'id' => 4, 'output' => '1', 'score' => 9, ), 3 => array ( 'id' => 5, 'output' => '0', 'score' => 10, ), 4 => array ( 'id' => 2, 'output' => '0', 'score' => 9, ), )

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:
24.69 ms | 406 KiB | 5 Q