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