Well, that should be it’s own thread, but…
So, you have a webpage and a list of PDF files. If you use GLOB to get the names, they are not sorted.
But, if you use the scandir() function, you can tell it to sort ASC and then they will be all set.
Example:
// Set a folder where the files are stored. This example is in the folder named “pdf” under the root folder.
$dir = “/pdfs/”;
// Sort in ascending order - this is default
$files = scandir($dir);
// Sort in descending order
$files = scandir($dir,1);
Then, use the foreach($files as $file) { to parse thru them in the order you want.
That is based on names of course. To order them by date of creation, you can do something like this:
(This uses the GLOB() function)
$dir = "/pdfs/";
$files = glob($dir.*.swf');
usort($files, function($a, $b) {
return filemtime($a) < filemtime($b);
});
Then, of course do the foreach to display them…
Hope this helps!