Edit report at http://bugs.php.net/bug.php?id=54617&edit=1
ID: 54617
User updated by: mike dot reinstein at freecause dot com
Reported by: mike dot reinstein at freecause dot com
Summary: inconsistent enclosure of characters in str_getcsv
Status: Open
Type: Bug
Package: Strings related
Operating System: centos, but probably others
PHP Version: 5.3.6
Block user comment: N
Private report: N
New Comment:
oops, code for example 2 is wrong. should be:
$input2 = "hey, \"let's\" see how, this works";
$result2 = str_getcsv($input2, ',', '"', '"');
print_r($result2);
Previous Comments:
------------------------------------------------------------------------
[2011-04-28 00:55:20] mike dot reinstein at freecause dot com
Description:
------------
str_getcsv will enclose strings differently depending on the contents of
the input
string. See the test script below for replication.
Test script:
---------------
$input = "hey, and\"let's\" see how, this works";
$result = str_getcsv($input, ',', '"', '"');
print_r($result);
$input2 = "hey, \"let's\" see how, this works";
$result2 = str_getcsv($input, ',', '"', '"');
print_r($result2);
Expected result:
----------------
Here's the output:
Array
(
[0] => hey
[1] => and"let's" see how
[2] => this works
)
Array
(
[0] => hey
[1] => let's see how
[2] => this works
)
Actual result:
--------------
Array
(
[0] => hey
[1] => and"let's" see how
[2] => this works
)
Array
(
[0] => hey
[1] => "let's" see how
[2] => this works
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54617&edit=1