Skip to content

Instantly share code, notes, and snippets.

Created September 26, 2015 20:21
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/223ea7353626bc6a6a9e to your computer and use it in GitHub Desktop.
Save anonymous/223ea7353626bc6a6a9e to your computer and use it in GitHub Desktop.
function csvPutEnclosed($file, $entries) {
$fp = fopen($file, 'a+');
foreach($entries as $entry) {
fputcsv($fp, array_map(function($v) { return "\"".str_replace('"', '\"', $v)."\"";}, $entry), ',', chr(0));
}
fclose($fp);
file_put_contents($file, str_replace(chr(0), '', file_get_contents($file)));
}
@mohammed-elattar
Copy link

Thank you so much for your efforts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment