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

From: Date: Sun, 27 Dec 2015 12:27:25 +0000
Subject: Bug #71226 [Opn->Nab]: fgetcsv does not split correctly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-198245@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71226&edit=1 ID: 71226 Updated by: requinix@php.net 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

« previous php.bugs (#198245) next »