I need to sort the following array in descending order by ref_no
. Eg: At location [0]
there should be property with id 16
(since its ref_no
is greater) and at [1]
property with id 10
.
$array = [
[
'Property' => ['id' => 10, 'member_id' => 2, 'ref_no' => 333]
],
[
'Property' => ['id' => 16, 'member_id' => 4, 'ref_no' => 509]
]
];
The size of the main array is dynamic and that of Property array remains same.
apply usort
usort($input, function ($a, $b) {return ($a['ref_no']>$b['ref_no']);});