php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54617 inconsistent enclosure of characters in str_getcsv
Submitted: 2011-04-28 00:55 UTC Modified: 2011-05-31 13:40 UTC
From: mike dot reinstein at freecause dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.3.6 OS: centos, but probably others
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
45 + 30 = ?
Subscribe to this entry?

 
 [2011-04-28 00:55 UTC] 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
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-04-28 00:57 UTC] mike dot reinstein at freecause dot com
oops, code for example 2 is wrong. should be:

$input2 = "hey, \"let's\" see how, this works";
$result2 = str_getcsv($input2, ',', '"', '"');
print_r($result2);
 [2011-05-31 13:40 UTC] iliaa@php.net
-Status: Open +Status: Bogus
 [2011-05-31 13:40 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Dec 03 20:01:23 2020 UTC