note 98254 added to function.fgetcsv
| From: | scottchu dot tw at gmail dot com | Date: | Fri, 04 Jun 2010 04:44:16 +0000 |
| Subject: | note 98254 added to function.fgetcsv | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-169881@lists.php.net to get a copy of this message | ||
I read in a utf8-encoded csv file with contents as follows:
"C1", "C2", "C3"
"chinese string 1", number, "string 3"
using following codes:
setlocale(LC_ALL, 'en_US.UTF-8');
...
while (($ar = fgetcsv($fp,0,",","\"")) != false) {
....
~~~
when I read 1st row (which is the field name list) & use print_r($ar) to dump it
I found 1st element of $ar is "C1" rather than C1. But other elements are ok.
fgetcsv treats the enclosing double quotes as part of value. What's wrong? Is it a bug?
----
Server IP: 69.147.83.197
Probable Submitter: 211.20.177.117
----
Manual Page -- http://www.php.net/manual/en/function.fgetcsv.php
Edit -- https://master.php.net/note/edit/98254
Del: integrated -- https://master.php.net/note/delete/98254/integrated
Del: useless -- https://master.php.net/note/delete/98254/useless
Del: bad code -- https://master.php.net/note/delete/98254/bad+code
Del: spam -- https://master.php.net/note/delete/98254/spam
Del: non-english -- https://master.php.net/note/delete/98254/non-english
Del: in docs -- https://master.php.net/note/delete/98254/in+docs
Del: other reasons-- https://master.php.net/note/delete/98254
Reject -- https://master.php.net/note/reject/98254
Search -- https://master.php.net/manage/user-notes.php