note 38059 deleted from function.filemtime by tomsommer
| From: | tomsommer@php.net | Date: | Wed, 01 Sep 2004 17:29:01 +0000 |
| Subject: | note 38059 deleted from function.filemtime by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-75861@lists.php.net to get a copy of this message | ||
Note Submitter: jackylee at eml dot cc
----
<?php
// is not a complete code but enough to delete files that older than 2 weeks.
// hope this can save your time :-)
$savepath = "data/jacky";
if ( is_dir("$savepath") )
{
$handle=opendir($savepath);
while (false!==($file = readdir($handle)))
{
if ($file != "." && $file != ".." && $file !=
"index.htm") // keep index.htm
{
$Diff = (time() - filemtime("$savepath/$file"))/60/60/24;
if ($Diff > 14) // 2 weeks ago
{ unlink("$savepath/$file"); }
}
}
closedir($handle);
}
?>