代码:
//当前路径
$cate=M(‘wangpan_class‘)->select();
function get_top_parentid($cate,$id){
$arr=array();
foreach($cate as $v){
if($v[‘id‘]==$id){
$arr[]=$v;// $arr[$v[‘id‘]]=$v[‘name‘];
$arr=array_merge(get_top_parentid($cate,$v[‘fid‘]),$arr);
}
}return $arr;
}
//return $r[‘id‘];
$zz=get_top_parentid($cate,‘18‘);
print_r($zz);
时间: 2024-12-14 07:06:05