Read csv file : CSV File « File Directory « PHP






Read csv file

 
<?php
$fh = fopen('csvdata.csv', 'rb');
if (! $fh) {
    die("Can't open csvdata.csv: $php_errormsg");
}

print "<table>\n";
       
for ($line = fgetcsv($fh, 1024); ! feof($fh); $line = fgetcsv($fh, 1024)) {
    print '<tr><td>' . implode('</td><td>', $line) . "</td></tr>\n";
}

print '</table>';
?>
  
  








Related examples in the same category

1.Generating comma-separated data
2.Making a CSV-formatted string
3.Parsing CSV Strings
4.Reading CSV data from a file
5.Tell the web client to view the CSV file in a seprate program
6.fgetcsv.php
7.Printing comma-separated data
8.Putting comma-separated data into a string