How to get the latest file name, or the file path that is added into a directory?
$dir = dirname(__FILE__).DIRECTORY_SEPARATOR; $lastMod = 0; $lastModFile = ''; foreach (scandir($dir) as $entry) { if (is_file($dir.$entry) && filectime($dir.$entry) > $lastMod) { $lastMod = filectime($dir.$entry); $lastModFile = $entry; } }