Enolamron Posted February 14, 2007 Share Posted February 14, 2007 I found this sniplet for making a slide show of images in a given folder. Not really sure how it sorts out the images but I was hoping to be able to do it by name. If someone could please take a look at this and give me a idea what I should be looking for it would be greatly appreciated. <?php Header("content-type: application/x-javascript"); $pathstring=pathinfo($_SERVER['PHP_SELF']); $locationstring="http://" . $_SERVER['HTTP_HOST'].$pathstring['dirname'] . "/"; function returnimages($dirname=".") { $pattern="(\.jpg$)|(\.png$)|(\.jpeg$)|(\.gif$)"; $files = array(); $curimage=0; if($handle = opendir($dirname)) { while(false !== ($file = readdir($handle))){ if(eregi($pattern, $file)){ echo 'picsarray[' . $curimage .']="' . $file . '";'; $curimage++; } } closedir($handle); } return($files); } echo 'var locationstring="' . $locationstring . '";'; echo 'var picsarray=new Array();'; returnimages() ?> Thank you Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted February 15, 2007 Share Posted February 15, 2007 Just before the line that reads return($files); insert this line: sort($files); http://www.php.net/sort http://www.php.net/natsort http://www.php.net/natcasesort Quote Link to comment 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.