|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-05-13 10:32 UTC] great_boba at yahoo dot com
Description:
------------
I try to write some application which parse csv-dump.
Below I write little example to show strange things.
Reproduce code:
---------------
1.csv
"A","B","C"
"A","B "","C """
1.php
<?php
$fp=fopen('1.csv',r');
while($data=fgetcsv($fp,4096,','))
print_r($data);
fclose($fp);
?>
Expected result:
----------------
Array
{
[0]=>A
[1]=>B
[2]=>C
}
Array
{
[0]=>A
[1]=>B "
[2]=>C ""
}
Actual result:
--------------
Array
{
[0]=>A
[1]=>B
[2]=>C
}
Array
{
[0]=>A
[1]=>B ",C """
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 21:00:01 2025 UTC |
This is expected. The "" is an escaped enclosure. Using: "A","B","C" "A","B ""","C """ Array ( [0] => A [1] => B " [2] => C " ) Use a proper format file.