Re: Read file dates for most recent
| From: | Bas Jobsen | Date: | Tue, 13 Aug 2002 21:37:29 +0000 |
| Subject: | Re: Read file dates for most recent | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-112446@lists.php.net to get a copy of this message | ||
Op dinsdag 13 augustus 2002 23:25, schreef Mike Davis:
> I need to read a directory full of PDF files, and get the file date of the
> most recent.
> Can someone get me started?
<?php
// Note that !== did not exist until 4.0.0-RC2
$dir='/home/allop/';
if ($handle = opendir($dir))
{
echo "Directory handle: $handle\n";
$lasttime=0;
$lastfile='';
while (false !== ($file = readdir($handle)))
{
if(is_file($file) && filemtime($file)>$latime)
{
$lasttime=filemtime($file);
$lastfile=$file;
}
}
}
echo $lastfile.':'.date('r',$lasttime),'\n';
?>