3v4l.org

run code in 300+ PHP versions simultaneously
<?php $yourArray = [ 'user 1' => [ ['item 4' => '11385'], ['item 2' => '144268'], ['item 1' => '65774'], ['item 9' => '98523'], ], 'user 5' => [ ['item 8' => '239233'], ], 'user 2' => [ ['item 4' => '53718'], ['item 1' => '154687'], ], ]; $newArray = array(); # start by sorting users $yourArray = ksort($yourArray); # then sort sub items foreach($yourArray as $user=>$theirItems) { $theirItems = ksort($theirItems); # assuming you still want to sort by key; $newArray[$user] = $theirItems; } var_dump($newArray);
Output for git.master_jit, git.master, rfc.property-hooks
Warning: foreach() argument must be of type array|object, true given in /in/lCC7P on line 25 array(0) { }

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:
45.44 ms | 2707 KiB | 4 Q