-
-
Save osde8info/ad9b9156e0fb2b6f0942 to your computer and use it in GitHub Desktop.
str_putcsv for php
This file contains 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 | |
/* From: http://www.php.net/manual/en/function.str-getcsv.php#88773 and http://www.php.net/manual/en/function.str-getcsv.php#91170 */ | |
if(!function_exists('str_putcsv')) | |
{ | |
function str_putcsv($input, $delimiter = ',', $enclosure = '"') | |
{ | |
$csv = fopen('php://temp','r+'); | |
fputcsv($csv, $input); | |
rewind($csv); | |
$output = stream_get_contents($csv); | |
fclose($csv); | |
return $output; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What are your thoughts about the original version that has
$data = fgets($fp);
instead of$output = stream_get_contents($csv);
? And any idea why it got -1 points while it seems to work well?