Re: Trying To Read - Show A Csv File Line By Line

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/20/2009 2:37 PM, "Kirk.Johnson@xxxxxxxxxxx" <Kirk.Johnson@xxxxxxxxxxx>
wrote:

> revDAVE <Cool@xxxxxxxxxxxxxxxx> 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]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux