Skip to content

Instantly share code, notes, and snippets.

@luckyshot
Last active May 8, 2017 19:54
Show Gist options
  • Save luckyshot/5395607 to your computer and use it in GitHub Desktop.
Save luckyshot/5395607 to your computer and use it in GitHub Desktop.
Array to CSV spreadsheet
<?php
function encodecsv($string) {
if(strpos($string, ',') !== false || strpos($string, '"') !== false || strpos($string, "\n") !== false) {
$string = '"' . str_replace('"', '""', $string) . '"';
}
return $string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment