i have a little php script that reads a directory and then echos all the files (jpg's in this case) into a jquery image slider. it works perfectly, but i dont know how to sort the images by name desending. at the moment the images are random.
<?php
$dir = 'images/demo/';
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
echo '<img src="'.$dir.$file.'"/>';
}
closedir($handle);
}
?>
any help on this would be great.
one more thing i dont understand. the script pics up 2 nameless non jpg files in that folder that does not exist??? but i havnt realy checked into that yet
$dir = 'images/demo/';
assume you only have.jpg
files in there. If not, it will show every file inside it. You could useforeach (glob("folder/*.jpg") as $dir) {
instead. – Gap