Hi
I have the following piece of code, which is then used by a flash application to display the pictures in a directory and make a slideshow.
How can I sort the files in the directory based on, let's say, filename?
PHP Code:
<images>
<?php
$dir = "slideshow/";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
$filetype = substr($file,-3);
$filetype = strtolower($filetype);
if ($filetype == "jpg" || $filetype == "gif") { ?>
<pic>
<image>slideshow/<?php echo $file;?></image>
<caption><?php echo $file;?></caption>
</pic>
<?php
}
}
closedir($dh);
}
}
?>
</images>
Thanks for the help.