PHP 二维数组根据某个字段排序
程序员文章站
2024-01-18 16:00:10
...
//数组顺序排列大小
function ArrMax($data,$arrkey){
$tree = array();
foreach ($data as $key=>$val)
{
$pro[]=$val[$arrkey];
}
array_multisort($pro,SORT_DESC);
for($j=0;$j<count($pro);$j++){
for($i=0;$i<count($data);$i++)
{
if($pro[$j]==$data[$i][$arrkey]){
$tree[$j] = $data[$i];
}
}
}
return $tree;
}
function ArrMax($data,$arrkey){
$tree = array();
foreach ($data as $key=>$val)
{
$pro[]=$val[$arrkey];
}
array_multisort($pro,SORT_DESC);
for($j=0;$j<count($pro);$j++){
for($i=0;$i<count($data);$i++)
{
if($pro[$j]==$data[$i][$arrkey]){
$tree[$j] = $data[$i];
}
}
}
return $tree;
}