Created
June 14, 2013 16:07
-
-
Save gabriel403/5783129 to your computer and use it in GitHub Desktop.
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
$output = fopen("php://output",'w') or die("Can't open php://output"); | |
header("Content-Type:application/csv"); | |
header("Content-Disposition:attachment;filename=pressurecsv.csv"); | |
fputcsv($output, ['email','status','created on', 'end date', 'last logged in', 'sales email']); | |
foreach($contentArray as $content) { | |
fputcsv($output, $content); | |
} | |
fclose($output) or die("Can't close php://output"); | |
exit; |
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
$response = $this->getResponse(); | |
$headers = $response->getHeaders(); | |
$headers->addHeaderLine('Content-Type', 'text/csv'); | |
$headers->addHeaderLine('Content-Disposition', "attachment; filename=\"pressurecsv.csv\""); | |
$headers->addHeaderLine('Accept-Ranges', 'bytes'); | |
$headers->addHeaderLine('Content-Length', strlen($content)); | |
$response->setContent($content); | |
return $response; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment