Sort My Array, by date?
Posted: Mon Oct 10, 2005 7:43 am
I'm using this code that I put to gether to list the files in a directory on my server, it works just how I want it except that it returns the list of files in Numerical and alphabetical order. How do I sort the file list into the date order, the files were added to the server?
Code: Select all
<?php
echo "<?xml version=\"1.0\" encoding =\"ISO-8859-1\" ?>\n";
echo "<images>\n";
if ($handle = opendir('images')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
list($width, $height) = getimagesize("images/".$file);
echo "<myImage myPath=\"images/" . "$file\"" . " myWidth=\"" . "$width\"" . " myHeight=\"". "$height\"" ." />\n";
}
}
closedir($handle);
}
echo "</images>\n"
?>