Bug #70491 [Fbk->NoF]: str_getcsv does not remove double quotes from the first row of a content

From: Date: Sun, 04 Sep 2016 04:22:24 +0000
Subject: Bug #70491 [Fbk->NoF]: str_getcsv does not remove double quotes from the first row of a content
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203776@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70491&edit=1 ID: 70491 Updated by: php-bugs@lists.php.net Reported by: msecco at gmx dot com Summary: str_getcsv does not remove double quotes from the first row of a content -Status: Feedback +Status: No Feedback Type: Bug Package: Filesystem function related Operating System: debian PHP Version: 5.6.13 Assigned To: cmb Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2016-08-26 13:20:52] cmb@php.net Related To: Bug #67566 ------------------------------------------------------------------------ [2016-08-26 13:07:04] cmb@php.net 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 <https://3v4l.org/V8Nug>. 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). ------------------------------------------------------------------------ [2015-09-14 13:43:14] 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 thanks ------------------------------------------------------------------------ [2015-09-14 13:39:48] msecco at gmx dot com Description: ------------ --- From manual page: http://www.php.net/function.str-getcsv --- Hi 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 bye 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"; } } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70491&edit=1

« previous php.bugs (#203776) next »