Seems inefficient to parse every line of the file with fgetcsv()
when you only care about the first and last line. As such, I'd use file() and str_getcsv():
$rows = file('data.csv');
$last_row = array_pop($rows);
$data = str_getcsv($last_row);
// loop and output data
Note: You can use the same logic for the headers by parsing $rows[0]
.