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