Jump to content

Directory Alphabetical Order Help Please!


Jaga

Recommended Posts

My image directory image (gif/jpg/png image) reader seems to not stay in alphabetical order. I'm not sure why.  :confused: 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();

?>

No longer need help. I finally solved my problem.  For those interested this was the fixed code.  :D

 

$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";

};

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.