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

WBOY
Release: 2016-07-13 10:29:32
Original
839 people have browsed it

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...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template