I have some code to display CSV file data in PHP. Out of these code is something like this
row1
row2
row3
row4
BLANK(this is not any data)
<?php
$csvFile = 'abc.csv';
$file_handle = fopen($csvFile, 'r');
while (!feof($file_handle) )
{
$csv_data[] = fgetcsv($file_handle, 1024);
}
fclose($file_handle);
foreach($csv_data as $data)
{
echo "column 2 = ".$data[1]; echo "<br>";
}
?>
expected output :
row1
row2
row3
row4
i have only these four rows but it prints 5 with last blank rows. Please suggest me the best solution. Thanks.