#41668 [Opn->Bgs]: fgetcsv(): wrong parse of double quote when combined with enclosure
| From: | tony2001@php.net | Date: | Tue, 03 Jul 2007 07:12:09 +0000 |
| Subject: | #41668 [Opn->Bgs]: fgetcsv(): wrong parse of double quote when combined with enclosure | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-114595@lists.php.net to get a copy of this message | ||
ID: 41668
Updated by: tony2001@php.net
Reported By: jkapicak at chip dot de
-Status: Open
+Status: Bogus
Bug Type: Filesystem function related
Operating System: Debian / Ubuntu
PHP Version: 5.2.3
New Comment:
"If a field's value contains a double quote character it is escaped by
placing another double quote character next to it."
Previous Comments:
------------------------------------------------------------------------
[2007-06-12 10:03:23] jkapicak at chip dot de
Description:
------------
If the double quote is close to enclosure, fgetcsv parses the line
wrong.
This is parsed wrong: "200"|"15,4""|"aa"
When escaped, it would work: "200"|"15,4\""|"aa"
Jozef
Reproduce code:
---------------
test.csv:
"200"|"15,4""|"aa"
"200"|"15,4 "|"aa"
text.php:
<?php
$aOut = array();
$handle = fopen("test.csv", "r");
while (($data = fgetcsv($handle, 100, '|', '"')) !== FALSE) {
print_r($data);
}
fclose($handle);
?>
Expected result:
----------------
Array
(
[0] => 200
[1] => 15,4"
[2] => aa
)
Array
(
[0] => 200
[1] => 15,4
[2] => aa
)
Actual result:
--------------
Array
(
[0] => 200
[1] => 15,4"|aa"
)
Array
(
[0] => 200
[1] => 15,4
[2] => aa
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41668&edit=1