Jaga Posted June 24, 2010 Share Posted June 24, 2010 My image directory image (gif/jpg/png image) reader seems to not stay in alphabetical order. I'm not sure why. I play a lot of TCG online card games and I organise my cards in different folders (collecting/future/trading and in each of those there catagories in this one fall/spring/summer/winter/special) and use this code a few times on the same page just I change the directory path mattering on which ones I want to display on the page. It current prints nothing if the directory is empty which I want it to stay like that or post a empty message. My problem is only the alphabetical order. It does everything else I need. Can anyone help me? :'( I've been trying anything I can find online for 2 days now! <?php $d = dir("cards/collecting/spring/"); $test = "cards/collecting/spring//"; while (false !== ($entry = $d->read())) { if ($entry == "."|| $entry == "..") { continue; } elseif (!ereg('gif|jpg|jpeg|png', $entry)) { continue; } echo "<img src=" . $test . $entry."\n" . "/> "; } $d->close(); ?> Link to comment https://forums.phpfreaks.com/topic/205792-directory-alphabetical-order-help-please/ Share on other sites More sharing options...
Jaga Posted June 24, 2010 Author Share Posted June 24, 2010 No longer need help. I finally solved my problem. For those interested this was the fixed code. $dirname = "cards/collecting/spring/"; $images = scandir($dirname); $ignore = Array(".", ".."); foreach($images as $curimg){ if(!in_array($curimg, $ignore)) { echo "<img src='$dirname${_SESSION['user']}/$curimg' />\n"; }; } Link to comment https://forums.phpfreaks.com/topic/205792-directory-alphabetical-order-help-please/#findComment-1076922 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.