/**
* 无限极分类
* @param $arr 所有分类
* @param $pid
* @param $step
* @return array
*/
public function getTree($arr,$pid,$step){
global $tree;
foreach($arr as $key=>$val) {
if($val['cid'] == $pid) {
$flg = str_repeat("└--",$step);
$val['title'] = $flg.$val['title'];
$tree[] = $val;
$this->getTree($arr , $val['id'] ,$step+1);
}
}
return $tree;
}
+ /**
+ * 获取该栏目的所有子栏目ids
+ * @param $id
+ * @param $ids
+ * @return array
+ * @author 宁佳兵 <meilijing.ning@foxmail.com>
+ */
+ public function getChild($id, &$ids)
+ {
+ $res = D("article_category")->where(["parent_id"=>$id])->select();
+ if (is_array($res)){
+ foreach ($res as $k=>$v){
+ $ids[] = $v['id'];
+ $this->getChild($v['id'],$ids);
+ }
+ }
+ return $ids;
+ }