php多维数组的排序
程序员文章站
2022-04-29 15:15:37
...
$aProduct = array( 0=> array('goods_id' => 1,'name' =>'iPhone 4','is_group' =>4), 1=> array('goods_id' => 2,'name' =>'iPhone 4s','is_group' =>6), 2=> array('goods_id' => 3,'name' =>'iPhone 5','is_group' =>1), 3=> array('goods_id' => 4,'name' =>'iPhone 5s','is_group' =>1) ); function arraySort($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(arraySort($aProduct,'is_group',SORT_DESC));exit;http://www.ruesin.com/php/array_multisort-12.html
以上就介绍了php多维数组的排序,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。