Home  >  Article  >  Backend Development  >  Dedecms function sharing to get all sub-columns of a certain column_PHP tutorial

Dedecms function sharing to get all sub-columns of a certain column_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:29:32804browse

I have never written recursion before (actually, if I think about it, I have no idea about algorithms), I happened to have this need, so I tried to write it and found that it is quite easy. I will record it in particular.

The database is the default of dedecms, dede_arctype is the table that saves the column, and reid is the parent column id of the column.

Copy code The code is as follows:

$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.htmlTechArticleI have never written recursion before (actually, think about it, I have no idea about algorithms). I just have this need. Try it. After writing it down, I found that it was quite easy, so I made a special note of it. The database is de...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn