Sort List But NOT After Date Has Passed.
| From: | Randum Ian | Date: | Sat, 01 Feb 2003 16:16:31 +0000 |
| Subject: | Sort List But NOT After Date Has Passed. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-133887@lists.php.net to get a copy of this message | ||
Hi guys, I have a script which looks in a directory, pulls out all the
files and sorts them by reverse date order. The file name schema is
"yyyymmdd-the rest of the file".
Script:
---
$interestingFile = array();
$interestingFiles = array();
$dir = opendir('/home/danceportal/www/uk/ian') or die( "Could not open
dir" );
while($dirEntry = readdir($dir)){
if(ereg("summary", $dirEntry) || ereg("full", $dirEntry)){
array_push($interestingFile, $dirEntry);
$date = explode("-", $dirEntry);
$finished = explode(".", $date[0]);
array_push( $interestingFiles, $finished[0]);
}
}
sort($interestingFile, SORT_REGULAR);
$count = count($interestingFile);
$k = $count;
$j = "0";
while($j < $count) {
$k --;
include $interestingFile[$k];
echo "<p>";
$j ++;
}
---
What I want to do is get today's date, then check each line against the
date and only show the rest of the files with the next one to expire and
so on.
Could someone help me with this please?
Cheers, Ian.