note 105945 added to function.getlastmod
| From: | erik dot stetina at gmail dot com | Date: | Tue, 27 Sep 2011 10:47:25 +0000 |
| Subject: | note 105945 added to function.getlastmod | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-183470@lists.php.net to get a copy of this message | ||
function for displaying last modification time accross more direcotries. e.g. to display last
modification date in "about" section of your web page
<?php
function array_prefix_values($prefix, $array)
{
$callback = create_function('$s','return
"'.$prefix.'".$s;');
return array_map($callback,$array);
}
function get_last_update()
{
if ( func_num_args() < 1 ) return 0;
$dirs = func_get_args();
$files = array();
foreach ( $dirs as $dir )
{
$subfiles = scandir($dir);
$subfiles = array_prefix_values($dir,$subfiles);
$subfiles = array_filter($subfiles,"is_file");
$files = array_merge($files,$subfiles);
}
$maxtimestamp = 0;
$maxfilename = "";
foreach ( $files as $file )
{
$timestamp = filemtime($file);
if ( $timestamp > $maxtimestamp )
{
$maxtimestamp = $timestamp;
$maxfilename = $file;
}
}
return date("Ymd",$maxtimestamp)." ($maxfilename)";
}
print "last update: ".get_last_update("./lib/", "./css/",
"./lang/");
?>
OUTPUT:
last update: 20110927 (./lang/sk.php)
----
Server IP: 69.147.83.197
Probable Submitter: 92.52.35.25
----
Manual Page -- http://www.php.net/manual/en/function.getlastmod.php
Edit -- https://master.php.net/note/edit/105945
Del: integrated -- https://master.php.net/note/delete/105945/integrated
Del: useless -- https://master.php.net/note/delete/105945/useless
Del: bad code -- https://master.php.net/note/delete/105945/bad+code
Del: spam -- https://master.php.net/note/delete/105945/spam
Del: non-english -- https://master.php.net/note/delete/105945/non-english
Del: in docs -- https://master.php.net/note/delete/105945/in+docs
Del: other reasons-- https://master.php.net/note/delete/105945
Reject -- https://master.php.net/note/reject/105945
Search -- https://master.php.net/manage/user-notes.php