Does PHP implement hierarchical tree display of data recursively? & Lt ;? Php $ db = mysql_connect ('localhost', 'root', 'root') ordie ('Can \ 'tconnecttodatabase'); mysql _ PHP recursively implements hierarchical tree-like display of data
?
$
My basic idea is to iterate through the array to determine if the current element has a sub-array named "Childs" recursively executes this function if any
$config = Array (' root ' = = Array (' childs ' = = Array (' body ' = = = Array (' childs ' =
A recursive function is a self-called function that calls itself directly or indirectly in the function body. However, you must set the self-called conditions. If the conditions are met, the function itself is called, if not, terminate the
Look at a simple recursive instanceExample 1 The code is as follows:Copy code Function demo ($ ){Static $ sum = 1;If ($ a> 1 ){$ Sum * = $;Demo (-- $ );} Else {$ A = $ sum; } Return $ sum;} Echo demo (10 ); Example 2Traverse
Copy Code code as follows:
The following code will draw a very beautiful leaf
Value that defines the angle of PI one point
Define ("PII", m_pi/180);
Creates a new image resource and defines its background as white, with a foreground color
This article illustrates how PHP recursively iterates through the files of a specified directory and counts the number of files. Share to everyone for your reference. The implementation methods are as follows:
"; Reads the current directory
Often asked to build the tree example, in fact, very simple, they write a, even if you throw a brick it. CSDN Forum Address: http://topic.csdn.net/u/20081029/11/f2faab7f-f8fb-43a8-906a-a7bb83063515.html + ":"-"; $name = $icon . $name;
Copy Code code as follows:
/*—————————————————— */
-Recursive implementation of infinite classification to generate a drop-down list function
– $tpl->assign (' Sort_list ', createsortoptions ());
– $tpl->assign (' Sort_list ',
Sometimes you need to create a directory function recursively, and you need to use the DirName () function (get the directory portion of the path) and the mkdir () function (create the directory).
First, popularize the grammar:
DirName
(PHP 4,
The following is a json recursive parsing class. I hope this example will help you, I don't need to talk about other issues. I will directly go to the code below to provide you with a json recursive parsing class. I hope this example will help you.
Recently, I am working on a markdown Parsing Library for the js version. I plan to migrate a popular library named Parsedown on the Internet to js completely, so that the front and back ends have the same display effect, however, I found that the
Copy codeThe Code is as follows:/*------------------*///-Recursively implement the infinite classification to generate the drop-down list Function//-$ Tpl-> assign ('sort _ list', createSortOptions ());//-$ Tpl-> assign ('sort _ list',
Ec (2); php payment recursive functions, which are called by themselves. These functions are especially suitable for browsing dynamic data structures, such as trees and lists. Almost no web applications require complex data structures & lt ;?
Recursive algorithm in PHP is not much of our data traversal method, let me introduce you to the use of recursion to do something.
See a simple recursive instance
Example 1
The code is as follows
Copy Code
function Demo ($
Sometimes you need to create a directory function recursively, you need to use the DirName () function (get the directory portion of the path) and the mkdir () function (create directory).
First, popularize the grammar:
DirName
(PHP 4, PHP
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.