I'm trying to display images in the reverse order of when they were last modified. Unfortunately, get_headers() seems to only work for urls, and both stat['mtime'] and filemtime() fail for me. Are there any other ways for me to get the last modified info for a file? Here's my code at the moment:
if (isset($_GET['start']) && "true" === $_GET['start'])
{
$images = array();
if ($dir = dir('images'))
{
$count = 0;
while(false !== ($file = $dir->read()))
{
if (!is_dir($file) && $file !== '.' && $file !== '..' && (substr($file, -3) === 'jpg' || substr($file, -3) === 'png' || substr($file, -3) === 'gif'))
{
$lastModified = filemtime($file);
$images[$lastModified] = $file;
++$count;
}
}
echo json_encode($images);
}
else { echo "Could not open directory"; }
}