I have this code that works fine, but I would like the last images to be uploaded to appear at the top of the page instead of appearing in a seemingly random order '.
They are not in a database, they are only in a folder where they use the move_uploaded_file(pics/....)
function.
$myDirectory = opendir("pics");
while($entryName = readdir($myDirectory)) {
$dirArray[] = $entryName;
}
closedir($myDirectory);
$indexCount = count($dirArray);
for($index=0; $index < $indexCount; $index++) {
$temp = explode('.', $dirArray[$index]);
$extension = strtolower(end($temp));
if ($extension == 'jpg' || $extension == 'png' || $extension == 'tif' || $extension == 'gif' || $extension == 'jpeg' || $extension == 'JPG'){
echo '<a href="pics/' . $dirArray[$index] . '"><img class="image" src="pics/' . $dirArray[$index] . '" alt="Image"></a>';
}
}