3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 2 => [ 'position' => 0, 'children' => [ 3 => ['position' => "375"], 5 => ['position' => "44"], 6 => ['position' => "567"], 9 => [ 'position' => "12", 'children' => [ 74 => ['position' => "2"], 76 => ['position' => "3"], 77 => ['position' => "1"], ] ], 62 => ['position' => "34"], 63 => ['position' => "11"], 66 => ['position' => "114"], 74 => ['position' => "912"], 76 => ['position' => "4564"], ] ] ]; function recur(&$data): void { uasort($data, fn($a, $b) => $a['position'] <=> $b['position']); foreach($data as &$value){ if (isset($value['children'])) { recur($value['children']); } } } recur($array); var_export($array);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 2 => array ( 'position' => 0, 'children' => array ( 63 => array ( 'position' => '11', ), 9 => array ( 'position' => '12', 'children' => array ( 77 => array ( 'position' => '1', ), 74 => array ( 'position' => '2', ), 76 => array ( 'position' => '3', ), ), ), 62 => array ( 'position' => '34', ), 5 => array ( 'position' => '44', ), 66 => array ( 'position' => '114', ), 3 => array ( 'position' => '375', ), 6 => array ( 'position' => '567', ), 74 => array ( 'position' => '912', ), 76 => array ( 'position' => '4564', ), ), ), )

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:
212.59 ms | 408 KiB | 5 Q