Home > Backend Development > PHP Tutorial > Categories of products related to drinking water hygiene and safety. Use PHP to implement recursive loops for each directory.

Categories of products related to drinking water hygiene and safety. Use PHP to implement recursive loops for each directory.

WBOY
Release: 2016-07-29 08:43:31
Original
1034 people have browsed it

The principle of the function is very simple, mainly using recursive calls.

Copy code The code is as follows:


function file_list($path){
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle)) )) {
if ($file != "." && $file != "..") {
if (is_dir($path."/".$file)) {
echo $path.": ". $file."
";//Remove this line to display all non-directory files
file_list($path."/".$file);
} else {
echo $path.": ". $file."
";
}
}
}
}
}


This function can also continue to make some improvements and add some folder or file icons, so that it can be made more powerful This is a function. Friends who are interested can expand it.

The above introduces the classification catalog of products related to drinking water hygiene and safety. Using PHP to implement a recursive cycle for each catalog includes the content of the classification catalog of drinking water hygiene and safety products. I hope it will be helpful to friends who are interested in PHP tutorials.

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