The principle of the function is very simple, the main is to use a recursive call.
Copy the Code code 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 all non-catalog files that are displayed on this line
File_list ($path. " /". $file);
} else {
echo $path. ":". $file. "
";
}
}
}
}
}
This function can also continue to make some improvements, add some folders or file icons or something, so you can make a more powerful function, interested friends can be extended.
The above describes the drinking water health and Safety product Classification directory with PHP to implement a recursive cycle of each directory, including the drinking water Health and Safety Product Classification directory aspects, I hope that the PHP tutorial interested friends helpful.