Php script for Listing files based on last modified time
Here is the php script to list the files in a folder based on the modified date
Using the below script you can list files from older to latest or latest to oldest
<?php
// list from a given folder
$folder="test/";
$files = glob( $folder."*.*" ); // to avoid hidden files
// Sort files by modified time, latest to oldest
array_multisort(array_map( 'filemtime', $files ),SORT_NUMERIC,SORT_DESC,$files);
// Use SORT_ASC in place of SORT_DESC for oldest to latest
//array_multisort(array_map( 'filemtime', $files ),SORT_NUMERIC,SORT_ASC,$files);
// display the file names
if(count($files)){
for( $i=0 ; $i < count($files) ; $i++ ){
echo(basename($files[$i])." <a href='".$folder.$files[$i]."'>Link to the file</a><br>");
}
}
?>
Hello,
ReplyDeleteI find out link of file modify time in php. & it can be Simple and helpful related to php developers
http://www.phphunt.com/124/file-modifey-time-in-php
This was helpful..Thanks for sharing..
ReplyDelete