自定义函数.php $i; $j--) { //如果该兼职的一维数组已经合并过 则跳过 if(in_array($i, $key_arr)){ continue; } if( $array[$i]['with1'] == $array[$j]['with1'] $array[$i]['with2'] == $array[$j]['with2'] ){ //记录要合并的
$i; $j--) { //如果该兼职的一维数组已经合并过 则跳过 if(in_array($i, $key_arr)){ continue; } if( $array[$i]['with1'] == $array[$j]['with1'] && $array[$i]['with2'] == $array[$j]['with2'] ){ //记录要合并的一维数组的键值 $key_arr[$n] = $j; $n++; $array[$i]['id_quantity']++; $array[$i]['id_stock_detail'] .= ','.$array[$j]['id_stock_detail']; } } } //释放掉合并过的一维数组 foreach ($key_arr as $value) { unset($array[$value]); } return $array; } /** *通过with 对数组排序 ,$order 为排序标准 SORT_DESC 降序;SORT_ASC 升序 *@Author Toby *@DateTime 2017-09-01 *@param [type] $array *@param [type] $with *@param [type] $order *@return [type] */ function arraysort($array,$with,$order) { $sort = array( 'direction' => $order, //排序顺序标志 'field' => $with, //排序字段 ); $arrSort = array(); foreach($array AS $uniqid => $row){ foreach($row AS $key=>$value){ $arrSort[$key][$uniqid] = $value; } } if($sort['direction']){ array_multisort($arrSort[$sort['field']], constant($sort['direction']), $array); } return $array; }