php无限级子类调用
2015-04-25 PHP 783
/**
获取分类所有子级
*/
function get_child_cat($catid,$field=\'id,pid,name\',$order=\'listorder asc\',&$level=0){
$max_level = 5; // 最大递归等级
$cate = D()->field($field)->from(\'catetorys
/** 获取分类所有子级 */ function get_child_cat($catid,$field='id,pid,name',$order='listorder asc',&$level=0){ $max_level = 5; // 最大递归等级 $cate = D()->field($field)->from('catetorys')->where(" pid in ( '". $catid."' )")->order($order)->select(); $cates = array(); if(!empty($cate)){ if($level++ > $max_level){ return $cates; } foreach($cate as $k=>$v){ $v['child'] = get_child_cat($v['id'],$field,$order,$level); $cates[] = $v; } return $cates; } }
很赞哦! (0)
相关文章
文章评论
-
-
-
0条评论