PHP 无限极分类

2020-08-19 12:23:28

php

PHP 无限极分类

    /**
     * 无限极分类
     * @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;
+    }

 

mysql php html server windows Excel Word Linux CAD

首页  返回列表

本站所有资料均来自网络,若有侵权请联系本站删除!粤ICP备18142546号