$infoArr = array( array('携程','is_read'=>0,'counts'=>1,'commenttime'=>'','comt'=>''), array('艺龙','is_read'=>0,'counts'=>2,'commenttime'=>'','comt'=>''), array('去哪儿','is_read'=>0,'counts'=>3,'commenttime'=>'','comt'=>''), array('大众点评','is_read'=>0,'counts'=>4,'commenttime'=>'','comt'=>''), array('美团','is_read'=>0,'counts'=>5,'commenttime'=>'','comt'=>''), ); $sort = array( 'direction' => 'SORT_DESC', //排序顺序标志 SORT_DESC 降序;SORT_ASC 升序 'field' => 'counts', //排序字段 ); $arrSort = array(); foreach($infoArr AS $uniqid => $row){ foreach($row AS $key=>$value){ $arrSort[$key][$uniqid] = $value; } } if($sort['direction']) { array_multisort($arrSort[$sort['field']], constant($sort['direction']), $infoArr); }
php二维数组排序
最新推荐文章于 2022-05-14 15:57:02 发布