递归根据父ID 找所有子类ID

Posted FinnYY

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了递归根据父ID 找所有子类ID相关的知识,希望对你有一定的参考价值。

function getinfo($pid){
    $str = ‘‘;
    $row = M(‘user‘)->where(array(‘pid‘=>$pid))->select();
    if($row){
        foreach($row as $key => $val ){
            $str .= ‘,‘.$val[‘id‘];
            $str .= getinfo($val[‘id‘]);
        }
    }
    return $str;
}

 

以上是关于递归根据父ID 找所有子类ID的主要内容,如果未能解决你的问题,请参考以下文章