$files = scandir(__DIR__, SCANDIR_SORT_DESCENDING);
At first I tried to check if there is a sort type for the date, but unfortunately I could not find it, so I decided to use filemtime
$latest = date("d Y H:i:s.");
printf($latest);
foreach($files as $value) {
if ($value != "..") {
if($value != ".") {
$latestnew = date("d Y", filemtime($value));
if($latestnew > $latest) {
$latest = $value;
}
}
}
}
printf($latest);
You can see that I have an array in which there are a lot of files. The last file name should be in the $ last variable. I know that checking ">" does not work, but I could not find another solution. Thank.
source
share