Source Code:
(back to article)
<?php $array = [ "John" => 32, "Mary" => 28, "Bob" => 45, "Jane" => 28, "David" => 37, ]; function compare($a, $b) { if ($a == $b) { return 0; } return $a < $b ? -1 : 1; } uasort($array, "compare"); print_r($array);
Result:
Report an issue