fanfavorite Posted December 5, 2007 Share Posted December 5, 2007 I use the opendir/readdir commands to read through and display all the images in a directory or multiple directories. What I am trying to do is say I have 200 images in the directory, I want to display 50 on a page and use previous and next buttons. The problem is that readdir seems to be in no particular order. Is there a way to force an order or so that I can split them properly? Quote Link to comment https://forums.phpfreaks.com/topic/80310-solved-opendirreaddir-order/ Share on other sites More sharing options...
shaymol Posted December 5, 2007 Share Posted December 5, 2007 Hi mate You can try with scandir method which second parameter is used for sorting order. For more info you can visit this page : http://www.php.net/manual/en/function.scandir.php. Thanks ShaymoL Quote Link to comment https://forums.phpfreaks.com/topic/80310-solved-opendirreaddir-order/#findComment-407092 Share on other sites More sharing options...
Guest Posted December 5, 2007 Share Posted December 5, 2007 You could try readdir once, cache the result in a sorted, serialized array in a session or flat file, and paginate through the cached array. That would eliminate extra I/O seeks, and would preserver order. Quote Link to comment https://forums.phpfreaks.com/topic/80310-solved-opendirreaddir-order/#findComment-407234 Share on other sites More sharing options...
fanfavorite Posted December 6, 2007 Author Share Posted December 6, 2007 thanks guys, both seem like they will work. Will give it a try. Quote Link to comment https://forums.phpfreaks.com/topic/80310-solved-opendirreaddir-order/#findComment-408187 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.