时间:2021-07-01 10:21:17 帮助过:34人阅读
代码如下:
foreach($areaArray as &$areas) {
$times = $numbers = array();
foreach($areas as $province => $v) {
$times[$province] = $v['times'];
$numbers[$province] = $v['numbers'];
}
array_multisort($times, SORT_DESC, $numbers, SORT_DESC, $areas);
}
代码如下:
$arr = array(
‘d' => array(‘id' => 5, ‘name' => 1, ‘age' => 7),
‘b' => array(‘id' => 2,'name' => 3,'age' => 4),
‘a' => array(‘id' => 8,'name' => 10,'age' => 5),
‘c' => array(‘id' => 1,'name' => 2,'age' => 2)
);
代码如下:
function multi_array_sort($multi_array,$sort_key,$sort=SORT_ASC){
if(is_array($multi_array)){
foreach ($multi_array as $row_array){
if(is_array($row_array)){
$key_array[] = $row_array[$sort_key];
}else{
return false;
}
}
}else{
return false;
}
array_multisort($key_array,$sort,$multi_array);
return $multi_array;
}
//处理
echo “
以上就介绍了数组 PHP 多维数组的排序问题 根据二维数组中某个项排序,包括了数组方面的内容,希望对PHP教程有兴趣的朋友有所帮助。