AndrewFerrara Posted January 28, 2011 Share Posted January 28, 2011 I am trying to display images on a html page alphabetically in descending order by their filename. <?php $dir = "./plate_cache"; $handle = opendir($dir); while (($file = readdir($handle))!==false) { if (strpos($file, '.png',1)) { echo "<img id=\"plates\" src=\"/tags/plate_cache/$file\"></a><br />;"; } } closedir($handle); } ?> Any help is greatly appreciated! Quote Link to comment Share on other sites More sharing options...
rondog Posted January 28, 2011 Share Posted January 28, 2011 you can add the filenames to an array then use sort: http://php.net/manual/en/function.sort.php Quote Link to comment Share on other sites More sharing options...
.josh Posted January 28, 2011 Share Posted January 28, 2011 use glob and rsort Quote Link to comment Share on other sites More sharing options...
AndrewFerrara Posted January 28, 2011 Author Share Posted January 28, 2011 could u fix the code I have little experience with php... what's an array? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted January 28, 2011 Share Posted January 28, 2011 what's an array? http://php.net/manual/en/language.types.array.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.