3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'note' => [], 'year' => ['2011','2010', '2012'], 'type' => ['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); foreach ($array[$columnKey] as $v) { $params[0][] = $priority[$v] ?? $default; } // assign reference variables to parameter array for all rows foreach ($array as &$row) { $params[] = &$row; } array_multisort(...$params); } array_multisort_custom($array, 'type', ['conference', 'journal']); var_export($array);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 'note' => array ( 0 => NULL, 1 => NULL, 2 => NULL, ), 'year' => array ( 0 => '2011', 1 => '2012', 2 => '2010', ), 'type' => 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:
27.91 ms | 406 KiB | 5 Q