note 88670 added to function.filectime
| From: | javi at live dot com | Date: | Tue, 03 Feb 2009 10:15:13 +0000 |
| Subject: | note 88670 added to function.filectime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-150138@lists.php.net to get a copy of this message | ||
Filemtime seems to return the date of the EARLIEST modified file inside a folder, so this is a
recursive function to return the date of the LAST (most recently) modified file inside a folder.
<?php
// Only take into account those files whose extensions you want to show.
$allowedExtensions = array(
'zip',
'rar',
'pdf',
'txt'
);
function filemtime_r($path)
{
global $allowedExtensions;
if (!file_exists($path))
return 0;
$extension = end(explode(".", $path));
if (is_file($path) && in_array($extension, $allowedExtensions))
return filemtime($path);
$ret = 0;
foreach (glob($path."/*") as $fn)
{
if (filemtime_r($fn) > $ret)
$ret = filemtime_r($fn);
// This will return a timestamp, you will have to use date().
}
return $ret;
}
?>
----
Server IP: 130.206.1.5
Probable Submitter: 80.25.157.230
----
Manual Page -- http://www.php.net/manual/en/function.filectime.php
Edit -- https://master.php.net/note/edit/88670
Del: integrated -- https://master.php.net/note/delete/88670/integrated
Del: useless -- https://master.php.net/note/delete/88670/useless
Del: bad code -- https://master.php.net/note/delete/88670/bad+code
Del: spam -- https://master.php.net/note/delete/88670/spam
Del: non-english -- https://master.php.net/note/delete/88670/non-english
Del: in docs -- https://master.php.net/note/delete/88670/in+docs
Del: other reasons-- https://master.php.net/note/delete/88670
Reject -- https://master.php.net/note/reject/88670
Search -- https://master.php.net/manage/user-notes.php