下面是实现代码:
function combine_same_val($array,$start,$key,$newkey){
static $new;
foreach($array as $k=>$v){
if($v[$key]==$start){
$new[$v[$newkey]][] = $v;
unset($array[$k]);
continue;
}
}
sort($array);
if(count($array)!==0){
combine_same_val($array,$array[0][$key],$newkey);
}
return $new;
}
原文链接:https://www.f2er.com/php/22486.htmlstatic $new;
foreach($array as $k=>$v){
if($v[$key]==$start){
$new[$v[$newkey]][] = $v;
unset($array[$k]);
continue;
}
}
sort($array);
if(count($array)!==0){
combine_same_val($array,$array[0][$key],$newkey);
}
return $new;
}