例子:
<?php
$arr = array(
0=>
array(
"id"=>"1208",
"fromid"=>"2",
"froms"=>"strategy",
"name"=>"",
"sort"=>"1"
),
1=>
array(
"id"=>"1209",
"fromid"=>"3",
"froms"=>"strategy",
"name"=>"",
"sort"=>"7"
),
2=>
array(
"id"=>"1210",
"fromid"=>"271",
"froms"=>"tag",
"name"=>"BC",
"sort"=>"2"
),
3=>
array (
"id"=>"1211",
"fromid"=>"263",
"froms"=>"tag",
"name"=>"777",
"sort"=>"3"
),
4=>
array (
"id"=>"1212",
"fromid"=>"262",
"froms"=>"tag",
"name"=>"6666",
"sort"=>"5"
),
5=>
array (
"choosecardtypeid"=>"1",
"fromid"=>"114",
"froms"=>"tagtype",
"sort"=>"4",
"name"=>"你还打算的"
),
6=>
array (
"choosecardtypeid"=>"1",
"fromid"=>"115",
"froms"=>"tagtype",
"sort"=>"6",
"name"=> "呵呵呵"
)
);
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;
}
print_r(multi_array_sort($arr,‘sort‘));