this code would usually output the filenames of images in a folder called img relative to
the php file and output it as an xml file for consumption by flex alphabetically
however it isn't doing that any more so I need your help how can I order my filenames
and echo them out in this while loop alphabetically?
Failing that what other alternatives can I use to the while loop
Code: Select all
<?php
//define the xml standard
header("Content-type: text/xml");
echo "<?xml version='1.0' encoding='ISO-8859-1'?>";
//this section calculates the image names in the directory
$imgdir = 'img/'; // the directory, where your images are stored
$allowed_types = array('png','jpg','jpeg','gif'); // list of filetypes you want to show
$dimg = opendir($imgdir);
echo "\n<gallery>
<image>\n";
while($imgfile = readdir($dimg))
{
if(in_array(strtolower(substr($imgfile,-3)),$allowed_types))
{
echo ' <url>img/' . $imgfile . "</url>\n";
}
}
echo ' </image>
</gallery>';
?>