Re: most latest file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Harpreet wrote:

Actually I have a backups folder that gets once a day backups of the
database automaticcaly. I want to be able to know the name fo the the latest
file to do the restore. The name of the files have the time stamp and plus
file has a time last mdified date attached to it.

How can I know which file got restored last using php and also the file
name.

Thanks

<?php


$directory = 'path/to/backups/directory';

$handle = opendir($directory) {
while (false !== ($file = readdir($handle))) {
  if ($file != "." && $file != ".." && fileatime($file) > $time) {
    $time = fileatime($file);
    $lastModifiedFile = $file;
  }
}

closedir($handle);
echo $lastModifiedFile;

?>

http://www.php.net/readdir
http://www.php.net/manual/en/function.fileatime.php

or, to check file creation times:

http://www.php.net/manual/en/function.filectime.php

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux