1--TEST-- 2Bug #69181 (READ_CSV|DROP_NEW_LINE drops newlines within fields) 3--FILE-- 4<?php 5$filename = __DIR__ . "/bug69181.csv"; 6$csv = <<<CSV 7"foo\n\nbar\nbaz",qux 8 9"foo\nbar\nbaz",qux 10CSV; 11 12file_put_contents($filename, $csv); 13 14$file = new SplFileObject($filename); 15$file->setCsvControl(escape: ""); 16$file->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE | SplFileObject::READ_CSV); 17var_dump(iterator_to_array($file)); 18 19echo "\n====\n\n"; 20 21$file->rewind(); 22while (($record = $file->fgetcsv())) { 23 var_dump($record); 24} 25?> 26--EXPECT-- 27array(2) { 28 [0]=> 29 array(2) { 30 [0]=> 31 string(12) "foo 32 33bar 34baz" 35 [1]=> 36 string(3) "qux" 37 } 38 [2]=> 39 array(2) { 40 [0]=> 41 string(11) "foo 42bar 43baz" 44 [1]=> 45 string(3) "qux" 46 } 47} 48 49==== 50 51array(2) { 52 [0]=> 53 string(12) "foo 54 55bar 56baz" 57 [1]=> 58 string(3) "qux" 59} 60array(2) { 61 [0]=> 62 string(11) "foo 63bar 64baz" 65 [1]=> 66 string(3) "qux" 67} 68--CLEAN-- 69<?php 70@unlink(__DIR__ . "/bug69181.csv"); 71?> 72