"PHP" reads "file list" in reverse chronological order, and recursively displays each level of directory,

Source: Internet
Author: User
"PHP" read "file list" in reverse chronological display, and recursively display each level of directory,!

Ideas:

1. Read the list of files in the directory where PHP is located, and use "Modify time, file name" as the key-value pair and plug in the array. Reverse the "Modified time". (seemingly unable to read the file list directly in reverse chronological order, here is the indirect method)

2. If the read is the direct output of the file, the directory is the output directory and recursively scan its next file.


 $file) {$file _path= "$path/$file";//Path $rel_path=str_replace (__dir__. ") /"," ", $file _path);//relative path//If-directory if (Is_dir ($file _path)) {//According to" directory Level "indent if (Substr_count ($file _path,"/") >1) {$count =str_repeat ("", Substr_count ($file _path, "/")); Echo $count. ' + '. $file;} Else{echo ' + '. $file;} echo "
"; Getdirfile ($file _path);} If-File Else{if (Substr_count ($file _path, "/") >1) {$count =str_repeat ("", Substr_count ($file _path, "/"); echo $ Count.getfile_html ($rel _path, $file). gettime_html ($mtime);} Else{echo getfile_html ($file, $file). gettime_html ($mtime);} echo "
";}}} function gettime_html ($time) {return '. Date (' (y-m-d h:m:s) ', $time) ';} function getfile_html ($rel _path, $file) {return '. $file. ';} -----------------------------------------$path =__dir__;getdirfile ($path);? >


Effect:




  • 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.