3v4l.org

run code in 300+ PHP versions simultaneously
<?php $people = array( array("name"=>"Bob","age"=>8,"colour"=>"red"), array("name"=>"Greg","age"=>12,"colour"=>"blue"), array("name"=>"Andy","age"=>5,"colour"=>"purple") ); $arrSortArray = array(); foreach($people as $person) { foreach($person as $key=>$value){ if(!isset($arrSortArray[$key])){ $arrSortArray[$key] = array(); } $arrSortArray[$key][] = $person; } } $orderby = "name"; //change this to whatever key you want from the array var_dump($arrSortArray[$orderby]); array_multisort($arrSortArray[$orderby], SORT_ASC,$people); var_dump($arrSortArray[$orderby]);
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { [0]=> array(3) { ["name"]=> string(3) "Bob" ["age"]=> int(8) ["colour"]=> string(3) "red" } [1]=> array(3) { ["name"]=> string(4) "Greg" ["age"]=> int(12) ["colour"]=> string(4) "blue" } [2]=> array(3) { ["name"]=> string(4) "Andy" ["age"]=> int(5) ["colour"]=> string(6) "purple" } } array(3) { [0]=> array(3) { ["name"]=> string(4) "Andy" ["age"]=> int(5) ["colour"]=> string(6) "purple" } [1]=> array(3) { ["name"]=> string(3) "Bob" ["age"]=> int(8) ["colour"]=> string(3) "red" } [2]=> array(3) { ["name"]=> string(4) "Greg" ["age"]=> int(12) ["colour"]=> string(4) "blue" } }

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:
47.66 ms | 403 KiB | 8 Q