- var_dump: documentation ( source)
- fputcsv: documentation ( source)
- preg_replace: documentation ( source)
- fclose: documentation ( source)
- fopen: documentation ( source)
<?php
$fp = fopen('php://output', 'w');
$input = ['some', 'random "stuff"', 'and \"shite\"', 'or \\\"more\\\"'];
foreach ($input as &$field) {
$field = preg_replace('~\\+"~', '"', $field);
var_dump(preg_replace('~\\\\+"~', '"', $field));
}
fputcsv($fp, $input);
fclose($fp);