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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mike dot reinstein at freecause dot com
New email:
PHP Version: OS:

 

 [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-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 14:01:31 2024 UTC