I found this cool picture viewer. It has a drop down box that gets populated by the files in a specified directory. The only problem is, there is no sort. I have beat my brains out trying to figure out how to sort this. Any ideas? Thanks!
It is called a Dynamic PHP Picture Viewer.
http://www.javascriptkit.com/script/script2/phpviewer/
SAMPLE:
QUESTION:
How would I get the picture list in alpha order?
PHP CODE:
<?
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()
?>