I have a directory that will be getting updated frequently, I want to display the last four images files uploaded, which match a certain pattern, on my php page.
Is this possible without having to perform a sort on every single image within the directory?
Many thanks!
You’ll always have to sort if you want the last four files, but you might as well let the filesystem do it for you. This will work on linux unless your pattern’s a regex:
If you have to use a regex, change the first two lines to