About PHP parsing CSV data and outputting

Source: Internet
Author: User
How does PHP parse CSV data and output it? This article mainly introduced PHP from the CSV file to read data and output to the Web page method, involving PHP fgetcsv function and the use of array traversal, I hope to help you

This example describes how PHP reads data from a CSV file and outputs it to a Web page. Share to everyone for your reference. The implementation method is as follows:


<?PHP$FP = fopen (' sample.csv ', ' r ') or Die ("can ' t Open file");p rint "<table>\n" and 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");? >

Related recommendations:

Phpexcel How to import an Excel code instance that handles big data

PHP fgetcsv () function syntax parameters enclosure detailed

Fgetcsv function reads the CSV file Chinese string problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.