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."
";
}
}
}
}
}
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.