Bug #71226 [Opn->Nab]: fgetcsv does not split correctly

[email protected]
Newsgroups php.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=71226&edit=1

 ID:                 71226
 Updated by:         [email protected]
 Reported by:        kingma at bluewin dot ch
 Summary:            fgetcsv does not split correctly
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            Streams related
 Operating System:   Windows 10
 PHP Version:        5.6.16
 Block user comment: N
 Private report:     N

 New Comment:

> fgetcsv($fh,$delimiter=';',$enclosure='"', $length=0);
Named arguments are not a thing. Call the function correctly.

http://php.net/manual/en/function.fgetcsv.php


Previous Comments:
------------------------------------------------------------------------
[2015-12-27 12:01:54] kingma at bluewin dot ch

Description:
------------
The lines are not split correctly at the delimiters, also enclosure characters end up in the resulting array.

Test script:
---------------
$fh = fopen('test_import.csv', "r");
$header = fgetcsv($fh,$delimiter=';',$enclosure='"', $length=0); //skip headers
print_r($header);echo "\n";
$line = fgetcsv($fh,$delimiter=';',$enclosure='"');
print_r($line);echo "\n";

test_import.csv contains
A;B;C;D;E;F
A;"B";C;"D";E;F


Expected result:
----------------
Array ( [0] => A; [1] => B [2] => C [3] => D [4] => E [5] => F )
Array ( [0] => A; [1] => B [2] => C [3] => D [4] => E [5] => F )

Actual result:
--------------
Array ( [0] => A;B;C;D;E;F )
Array ( [0] => A; [1] => B [2] => ;C; [3] => D [4] => ;E;F )


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=71226&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.