@ 2019-07-18T07:29:36Z <?php
$data = ['', '"', 'foo"', '\\"', '\\', 'foo\\'];
$input = fopen('php://temp,', 'w+');
fputcsv($input, $data, ',', '"', '');
rewind($input);
$csv = stream_get_contents($input);
var_dump($csv);
$output = fopen('php://temp', 'r+');
fwrite($output, $csv);
rewind($output);
var_dump($parsed = fgetcsv($output, 0, ',', '"', ''), $data === $parsed);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.7 string(27) ","""","foo""","\""",\,foo\
"
array(6) {
[0]=>
string(0) ""
[1]=>
string(1) """
[2]=>
string(4) "foo""
[3]=>
string(2) "\""
[4]=>
string(1) "\"
[5]=>
string(4) "foo\"
}
bool(true)
Output for 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 Warning: fputcsv(): escape must be a character in /in/fkQDt on line 5
string(0) ""
Warning: fgetcsv(): escape must be character in /in/fkQDt on line 15
bool(false)
bool(false)
preferences:dark mode live preview
181.9 ms | 402 KiB | 211 Q