<?php $data = array( array( 'id' => 5698, 'first_name' => 'Bill', 'last_name' => 'Gates', ), array( 'id' => 4767, 'first_name' => 'Steve', 'last_name' => 'Aobs', ), array( 'id' => 3809, 'first_name' => 'Mark', 'last_name' => 'Zuckerberg', ) ); //根据字段last_name对数组$data进行降序排列 $last_names = array_column($data,'last_name'); array_multisort($last_names,SORT_DESC,$data); var_dump($data);
array(3) {
[0]=>
array(3) {
["id"]=>
int(3809)
["first_name"]=>
string(4) "Mark"
["last_name"]=>
string(10) "Zuckerberg"
}
[1]=>
array(3) {
["id"]=>
int(5698)
["first_name"]=>
string(4) "Bill"
["last_name"]=>
string(5) "Gates"
}
[2]=>
array(3) {
["id"]=>
int(4767)
["first_name"]=>
string(5) "Steve"
["last_name"]=>
string(4) "Aobs"
}
}
?>