首页 > 编程语言 > 详细

多列表统计之后的数组排序

时间:2017-08-08 10:25:43      阅读:253      评论:0      收藏:0      [点我收藏+]
public function sortArray($ArrayData,$KeyName1,$SortOrder1 = "SORT_ASC",$SortType1 = "SORT_REGULAR"){
if(!is_array($ArrayData)) {
return $ArrayData;
}
// Get args number.
$ArgCount = func_num_args();
// Get keys to sort by and put them to SortRule array.
for($I = 1;$I < $ArgCount;$I ++) {
$Arg = func_get_arg($I);
if(!preg_match("/SORT/",$Arg)) {
$KeyNameList[] = $Arg;
$SortRule[] = ‘$‘.$Arg;
}
else {
$SortRule[] = $Arg;
}
}
// Get the values according to the keys and put them to array.
foreach($ArrayData AS $Key => $Info) {
foreach($KeyNameList AS $KeyName) {
${$KeyName}[$Key] = $Info[$KeyName];
}
}
// Create the eval string and eval it.
$EvalString = ‘array_multisort(‘.join(",",$SortRule).‘,$ArrayData);‘;
eval ($EvalString);
return $ArrayData;
}



$this->sortArray($list,$key,"SORT_DESC");

多列表统计之后的数组排序

原文:http://www.cnblogs.com/pcx105/p/7305274.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!