I am new to php so please be gentle. I am trying to sort the images I have in a gallery from newest to oldest. I have look online but its quite confusing. Any help would be appreciated.
<?php
$files = glob("Pictures/*.*");
for ($i=0; $i<count($files); $i++) {
$image = $files[$i];
print $image ."<br />";
echo '<img src="'.$image .'" alt="Random image" />'."<br /><br />";
}
// open this directory
$myDirectory = opendir("Pictures/");
// get each entry
while($entryName = readdir($myDirectory)) {
$dirArray[] = $entryName;
}
// close directory
closedir($myDirectory);
// count elements in array
$indexCount = count($dirArray);
?>