How to read data from csv file and output to web page_PHP tutorial

WBOY
Release: 2016-07-13 10:03:05
Original
1002 people have browsed it

How php reads data from a csv file and outputs it to the web page

The example in this article describes the method of php reading data from the csv file and outputting it to the web page. Share it with everyone for your reference. The specific implementation method is as follows:

<?php
$fp = fopen('sample.csv','r') or die("can't open file");
print "<table>\n";
while($csv_line = fgetcsv($fp)) {
  print '<tr>';
  for ($i = 0, $j = count($csv_line); $i < $j; $i++) {
    print '<td>'.htmlentities($csv_line[$i]).'</td>';
  }
  print "</tr>\n";
}
print '</table>\n';
fclose($fp) or die("can't close file");
?>
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/969342.htmlTechArticleHow php reads data from a csv file and outputs it to the web page. This example describes how php reads data from a csv file. And output to the web page. Share it with everyone for your reference. Specific implementation method...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template