How to use PHP & Read CSV file (Fgetcsv) Learn / tutorial php programming how to usingĀ PHP Read CSV (fgetcsv)
ShotDev Focus:
- PHP Read Csv
Example
php_csv_read.php
<html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <? $objCSV = fopen("shotdev/customer.csv", "r"); ?> <table width="600" border="1"> <tr> <th width="91"> <div align="center">CustomerID </div></th> <th width="98"> <div align="center">Name </div></th> <th width="198"> <div align="center">Email </div></th> <th width="97"> <div align="center">CountryCode </div></th> <th width="59"> <div align="center">Budget </div></th> <th width="71"> <div align="center">Used </div></th> </tr> <? while (($objArr = fgetcsv($objCSV, 1000, ",")) !== FALSE) { ?> <tr> <td><div align="center"><?=$objArr[0];?></div></td> <td><?=$objArr[1];?></td> <td><?=$objArr[2];?></td> <td><div align="center"><?=$objArr[3];?></div></td> <td align="right"><?=$objArr[4];?></td> <td align="right"><?=$objArr[5];?></td> </tr> <? } fclose($objCSV); ?> </body> </html>
Create a php file and save to path root-path/myphp/
Run
http://localhost/myphp/php_csv_read.php
Screenshot
2self-possessed…
…