<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ``` /** * 數組轉樹結構 * @param $list * @param $pk 當前節點 * @param $pid 父節點 * @param string $child 孩子節點 * @return array */ static function arrayToTree($list, $pk, $pid, $child = 'children') { $tree = array(); if (!is_array($list)) { return $tree; } $refer = array(); $parentNodeIdArr = []; foreach ($list as $key => $data) { $refer[$data[$pk]] = &$list[$key]; $parentNodeIdArr[$data[$pid]] = $data[$pid]; } /* 尋找根結點 */ foreach ($list as $key => $data) { if (in_array($data[$pk], $parentNodeIdArr)) { unset($parentNodeIdArr[$data[$pk]]); } } foreach ($list as $key => $data) { $parantId = $data[$pid]; if (in_array($parantId, $parentNodeIdArr)) { $tree[] = &$list[$key]; } else { if (isset($refer[$parantId])) { $parent = &$refer[$parantId]; $parent[$child][] = &$list[$key]; } } } return $tree; } ``` ``` /** * service層調用 * @param array $where * @return array */ public function getMenuTree($where = null){ // 把所有的欄目都查出來 $list = (new AdminMenu())->getByWhere($where)->toArray(); // 把數據轉成樹結構 return TreeUtil::arrayToTree($list,'id','pid'); } ``` ``` //調用前結果 array(114) { [0] =&gt; array(8) { ["id"] =&gt; int(1) ["pid"] =&gt; int(0) ["title"] =&gt; string(12) "系統管理" ["icon"] =&gt; string(8) "icon-set" ["sort"] =&gt; int(1) ["url"] =&gt; string(13) "Setting/index" ["url_type"] =&gt; string(6) "欄目" ["url_param"] =&gt; NULL } [1] =&gt; array(8) { ["id"] =&gt; int(5) ["pid"] =&gt; int(1) ["title"] =&gt; string(12) "系統配置" ["icon"] =&gt; string(11) "icon-set-sm" ["sort"] =&gt; int(1) ["url"] =&gt; string(13) "Setting/index" ["url_type"] =&gt; string(6) "欄目" ["url_param"] =&gt; NULL } [2] =&gt; array(8) { ["id"] =&gt; int(7) ["pid"] =&gt; int(2) ["title"] =&gt; string(12) "角色列表" ["icon"] =&gt; string(9) "icon-user" ["sort"] =&gt; int(1) ["url"] =&gt; string(10) "Role/index" ["url_type"] =&gt; string(6) "欄目" ["url_param"] =&gt; NULL } //調用后結果 array(10) { [0] =&gt; array(9) { ["id"] =&gt; int(1) ["pid"] =&gt; int(0) ["title"] =&gt; string(12) "系統管理" ["icon"] =&gt; string(8) "icon-set" ["sort"] =&gt; int(1) ["url"] =&gt; string(13) "Setting/index" ["url_type"] =&gt; string(6) "欄目" ["url_param"] =&gt; NULL ["children"] =&gt; array(1) { [0] =&gt; array(9) { ["id"] =&gt; int(5) ["pid"] =&gt; int(1) ["title"] =&gt; string(12) "系統配置" ["icon"] =&gt; string(11) "icon-set-sm" ["sort"] =&gt; int(1) ["url"] =&gt; string(13) "Setting/index" ["url_type"] =&gt; string(6) "欄目" ["url_param"] =&gt; NULL ["children"] =&gt; array(1) { [0] =&gt; array(8) { ["id"] =&gt; int(12) ["pid"] =&gt; int(5) ["title"] =&gt; string(13) "操作-修改" ["icon"] =&gt; string(0) "" ["sort"] =&gt; int(1) ["url"] =&gt; string(11) "Setting/add" ["url_type"] =&gt; string(6) "操作" ["url_param"] =&gt; NULL } } } } } ```
                  <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>

                              哎呀哎呀视频在线观看