I have a CSV file that contains four data fields:
date;place;time;event
First one is date, as you can see.
I need to read CSV line by line, compare DATE with current date and output ten lines starting from the line with current date.
I tried this code:
<?php
date_default_timezone_set("Europe/Zagreb");
$today = date('Ymd');
$file_handle = fopen("data.csv", "r");
while (!feof($file_handle) ) {
$line_of_text = fgetcsv($file_handle, 1024,";");
if ($line_of_text[0] >= $today) echo $line_of_text[0] . "-" . $line_of_text[1]. "-" . $line_of_text[2] . "-" . $line_of_text[3] . "<BR>";
}
fclose($file_handle);
?>
But I can't break that after 10 lines. I used YYYYMMDD date format in CSV and code so basically I work with numbers, not dates.