readdir - php read directory sorting -


i have little php script reads directory , echos files (jpg's in case) jquery image slider. works perfectly, dont know how sort images name desending. @ moment images random.

<?php $dir = 'images/demo/'; if ($handle = opendir($dir)) {  while (false !== ($file = readdir($handle))) {     echo '<img src="'.$dir.$file.'"/>'; }  closedir($handle); } ?> 

any on great.

one more thing dont understand. script pics 2 nameless non jpg files in folder not exist??? havnt realy checked yet

try this:

$dir = 'images/demo/'; $files = scandir($dir); rsort($files); foreach ($files $file) {     if ($file != '.' && $file != '..') {         echo '<img src="' . $dir . $file . '"/>';     } } 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -