|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-12-15 19:08 UTC] jordan dot raub at dataxltd dot com
Description:
------------
the documentation is misleading for fgetcsv.
\ is not the escape char for 5.2.8
double double quotes ("") will escape a double quote w/in a field.
I think the functionality is correct as is, so the docs should just be changed.
see http://en.wikipedia.org/wiki/Comma-separated_values
Reproduce code:
---------------
<?php
$fileContents = <<<EOD
"quote \"testing\"",""
"quote ""testing""",""
EOD;
$handle = fopen('php://memory', 'w');
fwrite($handle, $fileContents);
fseek($handle, 0);
while(!feof($handle))
{
var_dump(fgetcsv($handle));
}
Expected result:
----------------
array(2) {
[0]=>
string(15) "quote "testing""
[1]=>
string(4) "test"
}
array(2) {
[0]=>
string(17) "quote ""testing"""
[1]=>
string(4) "test"
}
Actual result:
--------------
array(2) {
[0]=>
string(17) "quote \"testing\""
[1]=>
string(4) "test"
}
array(2) {
[0]=>
string(15) "quote "testing""
[1]=>
string(4) "test"
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 23:00:01 2025 UTC |
tested w/ php5.3alpha3 and got this... array(2) { [0]=> string(17) "quote \"testing\"" [1]=> string(4) "test" } array(2) { [0]=> string(15) "quote "testing"" [1]=> string(4) "test" }