Forum Moderators: coopster
$date_from = mktime(0,0,0,$from_date_month,$from_date_day,$from_date_year);
$date_to = mktime(0,0,0,$to_date_month,$to_date_day,$to_date_year);
if (file_exists("../data/textdb.php")) {
$Data = file("../data/textdb.php");
$c = 0;
foreach($Data as $Line) {
list($entrydate,$userName,$userEmail) = explode("¦", $Line);}
$entrydate = trim($entrydate);
if($entrydate > $date_from && $entrydate < $date_to) {
$entrydate[$c] = strtok($Line,"¦");
$userName[$c] = strtok("¦");
$userEmail[$c] = strtok("¦");
$c++;
}
}
} And then goes on to echo the results...PROBLEM? It echoes NOTHING. What am I doing wrong? Can anyone help me? Is there another way to search for a time interval?
Thanks so much for your help.
Here's how I would do it:
if ( $Data = @file("../data/textdb.php") ) {
foreach($Data as $Line) {
$fields = explode("¦", $Line);
$date = trim($fields[0]);
if($date > $date_from && $date < $date_to) {
$entrydate[] = $fields[0];
$userName[] = $fields[1];
$userEmail[] = $fields[2];
}
}
You don't need to use a counter to set the array indexes. If you leave the brackets blank, they increment automatically. Hope it works for ya.
Birdman