Home  >  Article  >  Backend Development  >  PHP two-dimensional array sorted according to a certain field

PHP two-dimensional array sorted according to a certain field

巴扎黑
巴扎黑Original
2016-11-23 09:37:121213browse

//Array order size
function ArrMax($data,$arrkey){
$tree = array();
foreach ($data as $key=>$val)
{
$pro[]=$val [$arrkey];
}
array_multisort($pro,SORT_DESC);
for($j=0;$jfor($i=0;$i{
if($pro[$j]==$data[$i][$arrkey]){
$tree[$j] = $data[$i];
}
}
}
return $tree;
}


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn