How can I write quotation marks ("") in csv files using fputcsv. I tried:
'""'the result is written to csv file as""""""""\"\""The result is written to the csv file as\"\"
How can I write quotation marks ("") in csv files using fputcsv. I tried:
'""' the result is written to csv file as """""""
"\"\"" The result is written to the csv file as \"\"
fputcsv is escaping the double quotes because it uses a double quote as the default enclosure character for each field it writes. You can change which character fputcsv uses by passing a new character as a parameter to the function:
$fh = fopen('filename.csv', 'w');
$data = ['""'];
$delimiter = ','; // keep the delimiter as a comma
$enclosure = "'"; // set the enclosure to a single quote
fputcsv($fh, $data, $delimiter, $enclosure);
fclose($fh);