当前位置:Gxlcms > PHP教程 > dedecms函数分享之获取某一栏目所有子栏目_PHP教程

dedecms函数分享之获取某一栏目所有子栏目_PHP教程

时间:2021-07-01 10:21:17 帮助过:21人阅读

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

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

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/771873.htmlTechArticle以前从来没写过递归(其实想想,对算法完全没概念),刚好有这个需求,试着写了一下,发现也挺容易的,特别记录一下。 数据库是de...

人气教程排行