I've and array, I want to sort this array ascending order by [sys_title] key index. What should I do?
[0] => Array
(
[sys_id] => 9
[sys_title] => Checklist
[sys_home] => /cp/system/chl/
)
[1] => Array
(
[sys_id] => 8
[sys_title] => Bakery Ordering System
[sys_home] => /cp/system/bos/
)
Expected Result should be like this:
[0] => Array
(
[sys_id] => 8
[sys_title] => Bakery Ordering System
[sys_home] => /cp/system/bos/
)
[1] => Array
(
[sys_id] => 9
[sys_title] => Checklist
[sys_home] => /cp/system/chl/
)
答案 0 :(得分:1)
You can try this piece of code:
usort($data,function($a,$b){
return strcmp($a['sys_title'],$b['sys_title']);
});
print_r($data);
答案 1 :(得分:0)
假设您的阵列名称是$ a,那么:
Series
结果将是
$tmp = Array();
foreach($a as &$ma) {
$tmp[] = &$ma["sys_title"];
array_multisort($tmp, $a);
}