I have a csv file and have created the code to read the whole file into a table thus:
$table = "<table id='availabilitytableData'>\n\n";
$f = fopen("assets/temp/test.csv", "r");
while (($line = fgetcsv($f)) !== false) {
$table .= "<tr>";
foreach ($line as $cell) {
$table .= "<td style='font-size:9pt;'>" . htmlspecialchars($cell) . "</td>";
}
$table .= "</tr>\n";
}
fclose($f);
$table .= "\n</table>";
return $table;
What is the best approach to select say just the 4th row from the csv file? I have tried various approaches along the lines of
$line = file($f);//file in to an array
return $line[4];
which gives me the line I want but not in a formatted table. Other code snippets e.g. like this give clues but I can't seem to adapt them to my purpose. Bit stuck here I'm afraid any pointers are most welcome