Is there a way to select only the last file in a directory (with the extensions jpg|png|gif
?)
Or do I have to parse the entire directory and check using
function listdirfile_by_date($path)
{
$dir = opendir($path);
$list = array();
while($file = readdir($dir))
{
if($file != '..' && $file != '.')
{
$mtime = filemtime($path . $file) . ',' . $file;
$list[$mtime] = $file;
}
}
closedir($dir);
krsort($list);
foreach($list as $key => $value)
{
return $list[$key];
}
return '';
}