[PHP-BUG] Bug #71226 [NEW]: fgetcsv does not split correctly
[email protected] ("kingma at bluewin dot ch")
| Newsgroups | php.bugs |
|---|---|
| Message-ID | <[email protected]> |
From: kingma at bluewin dot ch
Operating system: Windows 10
PHP version: 5.6.16
Package: Streams related
Bug Type: Bug
Bug description:fgetcsv does not split correctly
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 bug report at https://bugs.php.net/bug.php?id=71226&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71226&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71226&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71226&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71226&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71226&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71226&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71226&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71226&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71226&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71226&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71226&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71226&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71226&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71226&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71226&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71226&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71226&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71226&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71226&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71226&r=mysqlcfg