Hi there,
I'm using opendir() and readdir() to make a file list, but I was wondering if it's possible to only show the 100 (or something) latest files.
Thanks.
File list, order and limit by date
Moderator: General Moderators
Re: File list, order and limit by date
See
- fileatime()
- filectime()
- filemtime()
- stat()
Re: File list, order and limit by date
Thanks, but I'm not sure how this would help me with only showing the 100 latest files.
Re: File list, order and limit by date
You will have to loop through all of the files and call one of the functions I listed to get a time for each file. Store the file names and times in two arrays or one two-dimensonal array. Sort the files based on the times using array_multisort() or usort(). (Need a hint?) To limit the number of files, use a loop to copy at most 100 elements to a new array or use array_slice().