Smedley Posted November 3, 2009 Share Posted November 3, 2009 Hi Guys, I have a page that sorts the contents (PDFs) of a directory and displays them on the webpage chronologically from the oldest (at top) to the newest (at bottom). I'd like to reverse this display order and have the latest files display at the top with oldest at the bottom. The code is seen below: Thanks in advance!!! <?php $dir = opendir('../../files/main/group/info'); $i = 0; // begin subdirectory processing $subdir = "../../files/main/group/info"."/"; $cwd = opendir($subdir); echo '<ul style="list-style: none;"><strong>'; while ($file = readdir($cwd)) { if (($file != ".") && ($file != "..") && ($file != "README.txt")) { $link = rawurlencode($file); $tmp = basename($file, ".pdf"); $filename = date('F d, Y',strtotime($tmp)); echo '<li><img src="../../images/icons/pdf.gif" alt="PDF Document" /> <a href="' . $subdir, $link . '" target="_blank">' . $filename . '</a>'; } } echo "</strong></ul>"; ?> Link to comment https://forums.phpfreaks.com/topic/180139-change-sort-order-to-display-newest-file-first/ Share on other sites More sharing options...
Smedley Posted November 5, 2009 Author Share Posted November 5, 2009 Wow! Nobody has any idea how to make this webpage list display in reverse order?? I thought it was probably a minor point for a guru...Please help if you're a PHP wiz... Link to comment https://forums.phpfreaks.com/topic/180139-change-sort-order-to-display-newest-file-first/#findComment-951845 Share on other sites More sharing options...
Smedley Posted November 18, 2009 Author Share Posted November 18, 2009 OK - this turned out to be a big help...not Link to comment https://forums.phpfreaks.com/topic/180139-change-sort-order-to-display-newest-file-first/#findComment-960298 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.