array sort php callback code example
Example: php usort keep keys
// Use "uasort" instead of "usort"
function order_asc($a, $b) {
return $b["popularity"] - $a["popularity"];
}
uasort(array, "order_asc");
// Use "uasort" instead of "usort"
function order_asc($a, $b) {
return $b["popularity"] - $a["popularity"];
}
uasort(array, "order_asc");