function inquireID1($cate_id){//返回数据会一直叠加
static $arrr= [];//静态变量
$sql = "select id,cate_name,pid from category where pid=$cate_id";
$rows = getAll($sql);
if ($rows){
foreach ($rows as $v ){
$arrr[]=$v['id'];
//递归查询
inquireID1($v['id']);
}
}
return $arrr;
}
function inquireID2($cate_id,&$arrr){返回数据不会叠加
$sql = "select id,cate_name,pid from category where pid=$cate_id";
$rows = getAll($sql);
if ($rows){
foreach ($rows as $v ){
$arrr[]=$v['id'];
//递归查询
inquireID2($v['id'],$arrr);
}
}
return $arrr;
}
![]()
![]()