web 2.0

How to use PHP & Read CSV file (Fgetcsv)

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

PHP & Read CSV file (Fgetcsv)
.
.
.

Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

One Response to “How to use PHP & Read CSV file (Fgetcsv)”

  1. 2self-possessed…

Leave a Reply

You must be logged in to post a comment.