php递归获取*父类id
function get_top_parentid($id){
$r = M('navclass')->where('id = '.$id)->field('id,f_id')->find();
if($r['f_id'] != '0') return get_top_parentid($r['f_id']);
return $r['id'];
}
echo get_top_parentid($postcid);
function get_top_parentid($id){
$r = M('navclass')->where('id = '.$id)->field('id,f_id')->find();
if($r['f_id'] != '0') return get_top_parentid($r['f_id']);
return $r['id'];
}
echo get_top_parentid($postcid);