3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $arr = array(); $arr[] = array("id" => 3, "name" => "joe"); $arr[] = array("id" => 34, "name" => "joe"); $arr[] = array("id" => 1, "name" => "joe"); $arr[] = array("id" => 15, "name" => "joe"); $arr[] = array("id" => 75, "name" => "joe"); $arr[] = array("id" => 2, "name" => "joe"); $arr[] = array("id" => 10, "name" => "joe"); $arr[] = array("id" => 19, "name" => "joe"); var_dump($arr); function cmp($a, $b) { //echo $a["id"] - $b["id"] ."\n\r"; return $a["id"] - $b["id"]; } usort($arr, "cmp"); var_dump($arr);
based on mWtI7
Output for 4.3.0 - 7.2.0
array(8) { [0]=> array(2) { ["id"]=> int(3) ["name"]=> string(3) "joe" } [1]=> array(2) { ["id"]=> int(34) ["name"]=> string(3) "joe" } [2]=> array(2) { ["id"]=> int(1) ["name"]=> string(3) "joe" } [3]=> array(2) { ["id"]=> int(15) ["name"]=> string(3) "joe" } [4]=> array(2) { ["id"]=> int(75) ["name"]=> string(3) "joe" } [5]=> array(2) { ["id"]=> int(2) ["name"]=> string(3) "joe" } [6]=> array(2) { ["id"]=> int(10) ["name"]=> string(3) "joe" } [7]=> array(2) { ["id"]=> int(19) ["name"]=> string(3) "joe" } } array(8) { [0]=> array(2) { ["id"]=> int(1) ["name"]=> string(3) "joe" } [1]=> array(2) { ["id"]=> int(2) ["name"]=> string(3) "joe" } [2]=> array(2) { ["id"]=> int(3) ["name"]=> string(3) "joe" } [3]=> array(2) { ["id"]=> int(10) ["name"]=> string(3) "joe" } [4]=> array(2) { ["id"]=> int(15) ["name"]=> string(3) "joe" } [5]=> array(2) { ["id"]=> int(19) ["name"]=> string(3) "joe" } [6]=> array(2) { ["id"]=> int(34) ["name"]=> string(3) "joe" } [7]=> array(2) { ["id"]=> int(75) ["name"]=> string(3) "joe" } }