Posts: 1,832
Location: Somewhere else entirely
|
PHP Code:
<?php clearstatcache(); $today = strtotime(date("d M Y")); $filelist = Array(); $times = Array(); if ($handle = opendir('images/')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $time = filemtime("images/".$file); if($today-$time <0) { $filelist[] = $file; $times[] = $time; } } } closedir($handle); }
array_multisort($times, SORT_NUMERIC, SORT_ASC, $filelist); ?> <style> td { border: solid 1px black; } th { border: solid 1px black; } </style> <table><tr> <th>Filename</th><th>Last Modified</th> </tr> <? for($i = 0; $i < count($filelist); $i++) { echo "<tr><td>".$filelist[$i]."</td><td>".date("jS M Y, h:i:s",$times[$i])."</td></tr>"; }
echo "</table>";
?>
Some explanation:
$today = strtotime(date("d M Y")); gets a timestamp value for the start of the day. By subtracting the file mod times from this, we can tell if it has been modified to day ( the result will be negative ).
the lines $filelist[] = $file; and $times[] = $time; are building up two arrays, one of times, and the other of files. Only files modified today will be in the lists.
array_multisort sorts both arrays by the time last modified, keeping the files with their times. To alter the sort order you can change SORT_ASC to SORT_DESC.
The rest of the code just prints it all out in a nice table.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';
Please login or register to view this content. Registration is FREE (aka MSN handwriting for forums)
|