[PHP-NOTES] note 130328 added to function.fputcsv

[email protected] ("[email protected]")
Newsgroups php.notes
Message-ID <[email protected]>
As stated above, if you want to parse the csv later with fgetcsv, you should disable the escape mechanism by setting the escape parameter to empty string. Here is what can happen if you don't:

<?php
$a = array('xyz\\', 'qwerty');
var_dump($a);
$f = fopen('test.csv', 'w');
fputcsv($f, $a);
fclose($f);

$f = fopen('test.csv', 'r');
$b = fgetcsv($f);
fclose($f);
var_dump($b);
?>

Result :

array(2) {
  [0]=>
  string(4) "xyz\"
  [1]=>
  string(6) "qwerty"
}
array(1) {
  [0]=>
  string(13) "xyz\",qwerty
"
}

As you can see, the output of fputcsv cannot be safely parsed by fgetcsv.
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 79.184.190.173)
----
Manual Page -- https://php.net/manual/en/function.fputcsv.php
Edit        -- https://main.php.net/note/edit/130328
Del: integrated  -- https://main.php.net/note/delete/130328/integrated
Del: useless     -- https://main.php.net/note/delete/130328/useless
Del: bad code    -- https://main.php.net/note/delete/130328/bad+code
Del: spam        -- https://main.php.net/note/delete/130328/spam
Del: non-english -- https://main.php.net/note/delete/130328/non-english
Del: in docs     -- https://main.php.net/note/delete/130328/in+docs
Del: other reasons-- https://main.php.net/note/delete/130328
Reject      -- https://main.php.net/note/reject/130328
Search      -- https://main.php.net/manage/user-notes.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.