3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [], ['2011','2010', '2012'], ['conference', 'journal', 'conference'], ]; function array_multisort_custom(array &$array, $columnKey, array $order) { // guard clause/condition if (!array_key_exists($columnKey, $array)) { throw new Exception('Nominated sorting column not found'); } // pad rows to consistent size $maxCount = max(array_map('count', $array)); array_walk($array, fn(&$row) => $row = array_pad($row, $maxCount, null)); // populate first sorting parameter with custom order array $priority = array_flip($order); $default = count($order); array_multisort( array_map(fn($v) => $priority[$v] ?? $default, $array[$columnKey]), ...$array ); } array_multisort_custom($array, 2, ['conference', 'journal']); var_export($array);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 0 => NULL, 1 => NULL, 2 => NULL, ), 1 => array ( 0 => '2011', 1 => '2012', 2 => '2010', ), 2 => array ( 0 => 'conference', 1 => 'conference', 2 => 'journal', ), )

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