dedecms中,擷取某一欄目所有子欄目_PHP教程

來源:互聯網
上載者:User
以前從來沒寫過遞迴(其實想想,對演算法完全沒概念),剛好有這個需求,試著寫了一下,發現也挺容易的,特別記錄一下。

資料庫是dedecms預設的,dede_arctype是儲存欄目的表,reid是欄目的父級欄目id。

$array = array();get_sons($type, $array);var_dump($array);function get_sons($type, &$current_array){    $result = mysql_query("select id from dede_arctype where reid = {$type}");    while($row = mysql_fetch_assoc($result)){        $current_array[] = $row['id'];        get_sons($row['id'], $current_array);    }}

http://www.bkjia.com/PHPjc/770662.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/770662.htmlTechArticle以前從來沒寫過遞迴(其實想想,對演算法完全沒概念),剛好有這個需求,試著寫了一下,發現也挺容易的,特別記錄一下。 資料庫是de...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.