|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70491 str_getcsv does not remove double quotes from the first row of a content
Submitted: 2015-09-14 13:39 UTC Modified: 2016-09-04 04:22 UTC
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: msecco at gmx dot com Assigned: cmb (profile)
Status: No Feedback Package: Filesystem function related
PHP Version: 5.6.13 OS: debian
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-09-14 13:39 UTC] msecco at gmx dot com
From manual page:

I'm using this function and it works well, only the first row for all its fields I need to use str_replace(array('"', "'"), "", $line[1]) and str_replace(array('"', "'"), "", $line[0]) to remove the double quotes. The rest of rows are ok
if the line is this
$data .= $line[1] . ' - ' . $line[0] . "\n";
I get the double quotes


Test script:
$content = file_get_contents($url);
$rows = explode("\n", $content);
foreach ($rows as $row) {
	if ($row) {
		$line = str_getcsv($row, "|", '"');
		if ($line[1] && $line[0])
			$data .= (int)str_replace(array('"', "'"), "", $line[1]) . ' - ' . str_replace(array('"', "'"), "", $line[0]) . "\n";


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-14 13:43 UTC] msecco at gmx dot com
the first fields are like
"Some text" and "2222" instead of
Some text and 2222 like present in the rest of rows

 [2016-08-26 13:07 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2016-08-26 13:07 UTC]
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with ,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

Actually, I can't reproduce the described behavior, see

BTW: reading the complete CSV file, exploding at line breaks and
processing the rows with str_getcsv() will only work if there are
no line breaks embedded in a field (what is allowed in CSV files).
 [2016-09-04 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Jan 17 00:01:23 2021 UTC