Edit report at http://bugs.php.net/bug.php?id=54617&edit=1
ID: 54617 Updated by: il...@php.net Reported by: mike dot reinstein at freecause dot com Summary: inconsistent enclosure of characters in str_getcsv -Status: Open +Status: Bogus 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: 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 Previous Comments: ------------------------------------------------------------------------ [2011-04-28 00:57:06] 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-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