php 递归 返回,php 递归返回值的问题

php 递归返回值的问题

请大佬帮我看看 递归循环 查找上级 在循环里面打印数据全部拿到了,但是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;

}

打印数据

404ceabc1942cbbe052b85588e0fdf6e.png

fed2a4d2da4f72609aae2a0ee8c9f7b0.png

返回数据

5c4f5b6dd938dc807cd25daaa2b408ba.png

4c7f867f4d3e6aa1f7ca6496a897536e.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值