I have this script that displays the contents of a directory in date order of last modified, but (there is always a but) I only want to display the latest modified files, ie within the last 5 days.
How can i parse my array to disregard files with a date greater than 5 days from today?
I also want to disregard any folders in that directory listing too, but i'm working on that at the moment.
<?
$handle = opendir ('my directory/');
while (($filename = readdir ($handle)) !== false)
{
if ($filename != '..' && $filename != '.')
{
$file_array[$filename] = filemtime ($filename);
}
}
arsort ($file_array);
echo '
<table border=0 cellspacing=0 cellpadding=2>
<tr class="title">
<td>Page name</td><td>Date updated</td>
</tr>
';
foreach ($file_array as $key => $value)
{
echo '<tr><td><a href="' . $key . '" class="content">' . $key . '</td><td class="content">' . date ('d-m-Y h:i:s', $value) . '</td></tr>';
}
echo '
</tr>
</table>
';
?>