ID: 20716 User updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Open -Bug Type: Unknown/Other Function +Bug Type: Filesystem function related Operating System: RedHat Linux 6.2 PHP Version: 4.3.0RC2 New Comment:
The correct output (4.2.3): array ( 0 => array ( 0 => 'f1', 1 => 'f2', 2 => 'f3', ), 1 => array ( 0 => 'Test 1a', 1 => 'Test 1b', 2 => 'Test 1c', ), 2 => array ( 0 => 'Test 2a', 1 => 'Test 2b - line 1 Test 2b - line 2 Test 2b - line 3', 2 => 'Test 2c', ), ) Incorrect output (4.3.0RC2): array ( 0 => array ( 0 => 'f1', 1 => 'f2', 2 => 'f3', ), 1 => array ( 0 => 'Test 1a', 1 => 'Test 1b', 2 => 'Test 1c', ), 2 => array ( 0 => 'Test 2a', 1 => 'Test 2b - line 1', ), 3 => array ( 0 => 'Test 2b - line 2', ), 4 => array ( 0 => 'Test 2b - line 3"', 1 => 'Test 2c', ), ) Previous Comments: ------------------------------------------------------------------------ [2002-11-29 04:52:52] [EMAIL PROTECTED] fgetcsv() was able to read multi-line fields that were quoted. Here is the example of the test file: f1;f2;f3 Test 1a;Test 1b;Test 1c Test 2a;"Test 2b - line 1 Test 2b - line 2 Test 2b - line 3";Test 2c We are trying to parse this file with the following code: $f = @fopen($argv[1], "r"); if (!$f) exit("Cannot open input file.\n"); $v = array(); while ($data = fgetcsv ($f, 10000, ";")) { $v[] = $data; } var_export($v); Now, in PHP 4.2.3 and earlier this produces correct 3 element array. PHP 4.3.0-dev produces 5 element array because it gets confused with the multiple line input in the 2b field. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=20716&edit=1