Bug #54617 [Opn]: inconsistent enclosure of characters in str_getcsv

From: Date: Wed, 27 Apr 2011 22:57:06 +0000
Subject: Bug #54617 [Opn]: inconsistent enclosure of characters in str_getcsv
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-160405@lists.php.net to get a copy of this message
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


Thread (3 messages)

« previous php.bugs (#160405) next »