"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: