[英]Sorting Multiple arrays in Desc order in PHP
I need to sort following array in desc order by ref_no
. 我需要通过ref_no
按顺序排序以下数组。 Eg: At location [0]
there should be property with id 16
(since it's ref_no
is greater) and at [1]
property with id 10
. 例如:在位置[0]
,应该有id为16
属性(因为它的ref_no
更大)和[1]
属性为id 10
。
*Please note: The size of main array is dynamic and that of Property array remains same. *请注意:主数组的大小是动态的,属性数组的大小保持不变。
Array
(
[0] => Array
(
[Property] => Array
(
[id] => 10
[member_id] => 2
[ref_no] => 333
}
)
[1] => Array
(
[Property] => Array
(
[id] => 16
[member_id] => 4
[ref_no] => 509
}
)
)
适用usort
usort($input, function ($a, $b) {return ($a['ref_no']>$b['ref_no']);});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.