note 103527 deleted from function.filemtime by danbrown
| From: | danbrown@php.net | Date: | Mon, 18 Apr 2011 17:29:11 +0000 |
| Subject: | note 103527 deleted from function.filemtime by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-178949@lists.php.net to get a copy of this message | ||
Note Submitter: upen at ncsu dot edu
----
// THE BEST WAY TO GET the FILENAME OF THE LAST //MODIFIED FILE - THANK ME !
$newstamp = 0;
$newname= "";
function dirTxt($dir1) {
$d1=dir($dir1);
while(false!== ($file1 = $d1->read()))
{
$extension1 = substr($file1, strrpos($file1, '.')); // Gets the File Extension
if ($extension1==".txt")
$logFiles[$file1]=$file1;
}
$d1->close();
return $logFiles;
}
//end of function
$arrayLogFiles= dirTxt('path/to/file/');
foreach ($arrayLogFiles as $key1 => $text1) // Display filename
{
$timedat = filemtime($text1);
if ($timedat > $newstamp) {
$newstamp = $timedat;
$newname = $text1;
}
}
echo $newname;