第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

php 遞歸返回值的問(wèn)題

php 遞歸返回值的問(wèn)題

PHP
ibeautiful 2019-03-10 08:10:19
php 遞歸返回值的問(wèn)題 請(qǐng)大佬幫我看看 遞歸循環(huán) 查找上級(jí) 在循環(huán)里面打印數(shù)據(jù)全部拿到了,但是return 返回?cái)?shù)據(jù)后卻是空,請(qǐng)問(wèn)是怎么回事?? 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) { //判斷是幾級(jí) $shu['one'] = $child[0]; $this->for_enter($child,$level,$shu); } } } } $array[] = $shu; } return $array; } 打印數(shù)據(jù) 返回?cái)?shù)據(jù)
查看完整描述

2 回答

?
慕尼黑8549860

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超11個(gè)贊

其實(shí)我看到你說(shuō)返回值為空我大概就知道問(wèn)題在哪里了,直接看了一下你遞歸調(diào)用函數(shù)的部分。如果沒(méi)錯(cuò)的話,你第一個(gè)應(yīng)該是直接進(jìn)入了 $child[0]['level'] == 4 的條件內(nèi),返回的直接為默認(rèn)的 $shu = array()

查看完整回答
反對(duì) 回復(fù) 2019-03-18
?
HUX布斯

TA貢獻(xiàn)1876條經(jīng)驗(yàn) 獲得超6個(gè)贊

在這個(gè)地方dump兩個(gè)值就知道了https://img1.sycdn.imooc.com//5c8f3dc400017d8d03580179.jpg

查看完整回答
反對(duì) 回復(fù) 2019-03-18
  • 2 回答
  • 0 關(guān)注
  • 718 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)