Classification of sanitary and safety products related to drinking water use PHP to implement recursive loops for each directory

Source: Internet
Author: User
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.

  • Contact Us

    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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.