I've a problem I'm trying to create a website where you can upload a pic and after the upload you see the pic that the previous user uploaded. The images are stored in a folder in my domain but I don't know how to sort them by date, actually I use this code but it didn't go very well
<?php
$search_dir = "uploads/".$row['Reference_No'];
$images = glob("$search_dir/*.jpg");
sort($images);
//display first image
if (count($images) > 0) { // at least one image exists
$img = $images[0];// first image
echo "<img src='../../$img' border='0' /> ";
} else {
shuffle($images);
echo "<img src='../../$images' border='0' /> ";
}