>
> Use the tool that PHP provides for such problems.
>
> http://php.net/fgetcsv
fgetcsv is very useful, here a example:
$num fields in line $row: \n";
$row++;
for ($c=0; $c < $num; $c++) {
echo $data[$c] . "\n";
}
}
fclose($handle);
?>
--
Gerardo Benitez
c...@hosting4days.com wrote:
On Oct 1, 2009, at 5:02 PM, Ben Dunlap wrote:
You could tackle this in a couple of different ways. Either split your
string into an array first:
$line = fgets($handle);
$columns = explode(",", trim($line));
Thanks Ben - the explode() command worked great!
Use
On Oct 1, 2009, at 5:02 PM, Ben Dunlap wrote:
You could tackle this in a couple of different ways. Either split your
string into an array first:
$line = fgets($handle);
$columns = explode(",", trim($line));
Thanks Ben - the explode() command worked great!
-
Now a bit of another pro
> $line = fgets($handle);
>
> list($col1, $col2, $col3) = $line;
[8<]
> echo "c1 is $col1 and c2 is $col2 and c3 is $col3".''; // this shows
> just 1st char of each field
That's odd, I would have expected $col1, $col2, and $col3 to be NULL.
That's what I get when I try to assign a string to list()
newbie import csv question
file is like:
stuff1,stuff2,stuff3
stuff1,stuff2,stuff3
stuff1,stuff2,stuff3
stuff1,stuff2,stuff3
etc.
Problem: when I try to parse out the 3 fields and display them using
list() it just gets just 1st char of each field ...
Q: How do I get it to set $col1 - 2 & $c
5 matches
Mail list logo