<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ## 控制器 ~~~ public function index(){ $data = db('menu')->order('listorder')->select(); $result = Menu::tree($data); p($result);exit; return view(); } ~~~ ## 模型 ~~~ <?php namespace app\admin\model; use think\Model; class Menu extends Model{ // 無限級分類,僅供教學使用 public static $treeListEasy = array(); public static function treeEasy($data, $parentid = 0){ foreach ($data as $key => $value) { if ($value['parentid'] == $parentid) { self::$treeListEasy[$value['id']][] = $value; self::treeEasy($data,$value['id']); } } return self::$treeListEasy; } // 無限級分類,僅供教學使用 public static $treeListTest = array(); public static $pid = 0; public static $sid = 0; public static function treeTest($data, $parentid = 0, $level = 1){ foreach ($data as $key => $value) { if ($value['parentid'] == $parentid) { if ($level == 1) { self::$pid = $value['id']; self::$treeListTest[self::$pid] = $value; }else if ($level == 2) { self::$sid = $value['id']; self::$treeListTest[self::$pid]['son'][self::$sid] = $value; }elseif ($level == 3) { self::$treeListTest[self::$pid]['son'][self::$sid]['son'][] = $value; } if ($value['child']) { self::treeTest($data, $value['id'], $level+1); } } } return self::$treeListTest; } // 無限級分類,開發使用 public static function tree($data){ $tree = []; // 第1步,將所有菜單項的ID作為數組下標 foreach ($data as $value) { $tree[$value['id']] = $value; } // 第2步,利用引用的方式,將每個子菜單項添加到父類son的數組中,只需遍歷一次 foreach ($tree as $key => $value) { if ($value['parentid'] != 0) { $tree[$value['parentid']]['son'][] = &$tree[$key]; } } // 第3步,清除重復數據 foreach ($tree as $key => $value) { if ($value['parentid'] != 0) { unset($tree[$key]); } } return $tree; } // 無限級分類,開發使用(優化@2018.6.7) public static function tree($data){ $tree = []; //第1步,將所有菜單項的ID作為數組下標 foreach ($data as $value) { $tree[$value['id']] = $value; } //利用引用的方式,將每個子菜單項添加到父類son的數組中,只需遍歷一次 foreach ($tree as $key => $value) $tree[$value['parentid']]['son'][] = &$tree[$key]; $tree = isset($tree[0]['son']) ? $tree[0]['son'] :array(); //原第3步,清除重復數據,已經不需要使用 // foreach ($tree as $key => $value) { // if($value['parentid'] !=0 ){ // unset($tree[$key]); // } // } return $tree; } } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看