Created
June 23, 2009 17:45
-
-
Save jwheare/134706 to your computer and use it in GitHub Desktop.
php array to csv line
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 | |
// Encode an array to a CSV delimited row using PHP's memory output buffer | |
// http://php.net/manual/en/wrappers.php.php | |
function array_to_csv_line($data_array) { | |
$temp_mem = fopen("php://temp", 'r+'); | |
fputcsv($temp_mem, $data_array); | |
rewind($temp_mem); | |
$data_csv = trim(stream_get_contents($temp_mem)); | |
return $data_csv; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment