Last active
May 8, 2017 19:54
-
-
Save luckyshot/5395607 to your computer and use it in GitHub Desktop.
Array to CSV spreadsheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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