I have an array as following and I want to order that array ascending and descending by the value of the key "min_price". I tried and I followed this link still not working properly. Any help would be greatly appreciated.
This is the array:
Array
(
[0] => Array
(
[property_id] => 116
[min_price] => 3487
)
[1] => Array
(
[property_id] => 131
[min_price] => 3035
)
[2] => Array
(
[property_id] => 171
[min_price] => 7999
)
)
function cmp($a, $b) {
if ($a['min_price'] == $b['min_price']) {
return 0;
}
return ($a['min_price'] < $b['min_price']) ? -1 : 1;
}
uasort($data, 'cmp');
I want to use this array ascending and descending order.