Home >Backend Development >PHP Tutorial >How to read data from csv file in php and output it to the web page, _PHP tutorial

How to read data from csv file in php and output it to the web page, _PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:03:48809browse

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

The example in this article describes how php reads data from a csv file and outputs it to a web page. Share it with everyone for your reference. The specific implementation method is as follows:

<&#63;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");
&#63;>

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/967736.htmlTechArticleHow php reads data from a csv file and outputs it to the web page. The example in this article describes how php reads data from a csv file. Data and output to the web page. Share it with everyone for your reference. Specific implementation method...
Statement:
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