<?php
$dir = ‘/path/to/dir’;
if ($handle = opendir($dir))
{
while (false !== ($file = readdir($handle)))
{
if ($file[0] == ‘.’ || is_dir(“$dir/$file”))
{
// ignore hidden files and directories
continue;
}
if ((time() – filemtime($file)) > ($days *86400))
{
//note this is using the unlink function
unlink(“$dir/$file”);
}
}
closedir($handle);
}
?>
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
