请大佬帮我看看 递归循环 查找上级 在循环里面打印数据全部拿到了,但是return 返回数据后却是空,请问是怎么回事??
public function for_enter($data=array(),$level=0,$shu=array(),$s=0){
$ui = M('ui');
$array = array();
$where['is_enter'] = 1;
foreach ($data as $k => $v) {
$child = $ui->where(array('code'=>$v['pcode']))->select();
if (empty($child)) {
return '';
}else{
if ($child[0]['level'] == 4) {
$this->for_enter($child,$level,'');
}else{
if ($child[0]['is_enter'] == 1) {
if (($level - $child[0]['level']) == 3) {
$shu['three'] = $child[0];
$this->for_enter($child,$level,$shu);
}
if (($level - $child[0]['level']) == 2) {
$shu['tow'] = $child[0];
$this->for_enter($child,$level,$shu);
}
if (($level - $child[0]['level']) == 1) {
//判断是几级
$shu['one'] = $child[0];
$this->for_enter($child,$level,$shu);
}
}
}
}
$array[] = $shu;
}
return $array;
}
打印数据
返回数据
慕尼黑8549860
HUX布斯