File Directory Php

$dir2clean = 'cache';
$test = false;
$more = false;
$output = '';
if ($handle = opendir($dir2clean))
{
$header = "\n";
$i = 0;
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle)) && $i < 105)
{
if ( $i < 100)
{
$output .= "$file\n";
if (substr($file, 0, 1) != '.')
{
if ($test) $output .= 'test';
elseif (unlink("{$dir2clean}/{$file}")) $output .= "deleted";
else $output .= "kept";
}
else $output .= ' ';
$output .= "";
$output .= date ("F d Y H:i:s.", fileatime("cache/{$file}"));
$output .= "\n\n";
}
else $more = true;
$i++;
}
closedir($handle);
}
?>


// meta refresh can fail in Internet Explorer but this works like a rocket in Firefox
if ($more && !$test)
{
echo "\n\n";
}
?>


Date:

Directory:

Files: