标签:cti return esc var 数组 else 二维数组 asc type
/*$arr 数组
* $name 排序依据列
* $asc asc正序 desc 倒序
* */
function arr_sort($arr,$name,$type=‘asc‘){
$temp=array();
foreach($arr as $v){
$temp[$v[$name]]=$v;
}
if($type==‘asc‘){
ksort($temp);
}else{
krsort($temp);
}
return $temp;
}
$attr2=array(
array("id"=>1,"name"=>"liming","age"=>21),
array("id"=>3,"name"=>"daten","age"=>27),
array("id"=>2,"name"=>"xiaohua","age"=>18),
);
echo "<pre>";
var_dump(arr_sort($attr2,"age"));
标签:cti return esc var 数组 else 二维数组 asc type
原文地址:http://www.cnblogs.com/lixiuyuan999/p/6393279.html