Re: Trying To Read - Show A Csv File Line By Line
| From: | revDAVE | Date: | Sat, 21 Mar 2009 00:01:52 +0000 |
| Subject: | Re: Trying To Read - Show A Csv File Line By Line | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-290457@lists.php.net to get a copy of this message | ||
On 3/20/2009 2:37 PM, "Kirk.Johnson@zootweb.com" <Kirk.Johnson@zootweb.com>
wrote:
> revDAVE <Cool@hosting4days.com> wrote on 03/20/2009 03:11:00 PM:
>
>> Newbie ... I'm trying to Trying to read / show a csv file line by line
> ...
>
> fgetcsv is your friend.
>
> http://us.php.net/manual/en/function.fgetcsv.php
Thanks Kirk for your help....
Hmmm - when I tried this example on the link - it echoed every field on it's
own line - but did NOT recognize the returns (each row) of the csv...
Q: how do I just pull out 1 whole row at a time?
<?php
$row = 1;
$handle = fopen("try3.csv", "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
for ($c=0; $c < $num; $c++) {
echo $data[$c] . "<br />\n";
}
}
fclose($handle);
?>
--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists 09]