I've modified and cleaned this PHP script that someone else wrote. Locally on my WAMP server it lists the images alphabetically (they're all named 001.jpg ~ 110.jpg) however on the live LAMP server I think they're organized by date modified...whatever it is it's not by file name. They're all JPEG images so I'm not worried about arranging by type.
So, how do I modify this script to list images alphabetically please?
function getPictures()
{
global $page, $per_page, $has_previous, $has_next;
if ($handle = opendir('tour/'))
{
$lightbox = rand();
echo '<ul id="pictures">';
$count = 0;
$skip = $page * $per_page;
if ($skip != 0 ) {$has_previous = true;}
while ($count < $skip && ($file = readdir($handle)) !== false )
{
if (!is_dir($file) && ($type = getPictureType($file)) != '' ) {$count++;}
}
$count = 0;
while ( $count < $per_page && ($file = readdir($handle)) !== false )
{
if (!is_dir($file) && ($type = getPictureType($file)) != '' )
{
if (!is_dir('thumbs/')) {mkdir('thumbs/');}
if (!file_exists('thumbs/'.$file)) {makeThumb('tour/'.$file,$type );}
echo '<li><a href="tour/'.$file.'" rel="lightbox['.$lightbox.']">';
echo '<img src="thumbs/'.$file.'" alt="" />';
echo '</a></li>';
$count++;
}
}
echo '</ul>';
while (($file = readdir($handle)) !== false)
{
if (!is_dir($file) && ($type = getPictureType($file)) != '' )
{
$has_next = true;
break;
}
}
}
}