首页 > 学院 > 开发设计 > 正文

dedecms中,获取某一栏目所有子栏目

2019-11-15 01:35:41
字体:
来源:转载
供稿:网友
dedecms中,获取某一栏目所有子栏目

以前从来没写过递归(其实想想,对算法完全没概念),刚好有这个需求,试着写了一下,发现也挺容易的,特别记录一下。

数据库是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);    }}


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表