laravel调用一个递归函数总是错误,传参是一个数组返回也是一个,求解?
public function all()
{
$shopType = ShopType::getAllType();
$result=$this->menu_merge($shopType,0);
dump($result);
}
public function cateDivide($menu,$pid=0)
{
$arr=array();
foreach($menu as $v) {
if($v['parent']==$pid){
$v['child']=$this->cateDivide($menu,$v['id']);
$arr[]=$v;
}
}
return $arr;
}
1 Comment
@MeizitaiTT#209 递归写的有问题