Skip to content

Instantly share code, notes, and snippets.

@ericcholis
Last active December 24, 2015 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericcholis/6717291 to your computer and use it in GitHub Desktop.
Save ericcholis/6717291 to your computer and use it in GitHub Desktop.
Lithium CSV Media Handler
<?php
Media::type('csv', 'text/plain', array(
'encode' => function($data) {
ob_start();
$out = fopen('php://output', 'w');
foreach ($data as $record) {
fputcsv($out, $record);
}
fclose($out);
return ob_get_clean();
}
));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment