note 35779 added to function.filemtime

From: Date: Sun, 14 Sep 2003 18:17:03 +0000
Subject: note 35779 added to function.filemtime
Groups: php.notes 
Request: Send a blank email to php-notes+get-56475@lists.php.net to get a copy of this message
Another little handy tool; to get the most recent modified time from files in a directory. It even does recursive directories if you set the $doRecursive param to true. Based on a file/directory list function I saw somewhere on this site. ;) function mostRecentModifiedFileTime($dirName,$doRecursive) { $d = dir($dirName); $lastModified = 0; while($entry = $d->read()) { if ($entry != "." && $entry != "..") { if (!is_dir($dirName."/".$entry)) { $currentModified = filemtime($dirName."/".$entry); } else if ($doRecursive && is_dir($dirName."/".$entry)) { $currentModified = mostRecentModifiedFileTime($dirName."/".$entry,true); } if ($currentModified > $lastModified){ $lastModified = $currentModified; } } } $d->close(); return $lastModified; } ---- Manual Page -- http://www.php.net/manual/en/function.filemtime.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35779 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35779&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35779&report=yes

« previous php.notes (#56475) next »