Bug #70491 [Opn]: str_getcsv does not remove double quotes from the first row of a content
| From: | msecco at gmx dot com | Date: | Mon, 14 Sep 2015 13:43:15 +0000 |
| Subject: | Bug #70491 [Opn]: 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-196000@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
User updated by: msecco at gmx dot com
Reported by: msecco at gmx dot com
Summary: str_getcsv does not remove double quotes from the
first row of a content
Status: Open
Type: Bug
Package: Filesystem function related
Operating System: debian
PHP Version: 5.6.13
Block user comment: N
Private report: N
New Comment:
the first fields are like
"Some text" and "2222" instead of
Some text and 2222 like present in the rest of rows
thanks
Previous Comments:
------------------------------------------------------------------------
[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