Last active
December 26, 2015 11:18
-
-
Save ajbonner/7142414 to your computer and use it in GitHub Desktop.
A version of putcsv that returns a string rather than writes to a file
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 | |
/** | |
* @param array $data | |
* @return string | |
*/ | |
public function str_putcsv($data) | |
{ | |
$fh = fopen('php://memory', 'rwb'); | |
fputcsv($fh, $data); | |
fseek($fh, 0); | |
$csv = fgets($fh); | |
fclose($fh); | |
return $csv; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment