Last active
August 29, 2015 14:19
-
-
Save twysto/5baec9934b54e456893d to your computer and use it in GitHub Desktop.
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
public function exportCSV() { | |
$filename = 'export.csv'; | |
$sep = chr(9); // ASCII 009 (Horizontal Tab) | |
$output = 'sep='.$sep."\n"; | |
$output .= 'Email'.$sep.'Firstname'."\n"; | |
$subscribers = $this->_dao->findNewsletterSubscribers(); // Query Database | |
foreach($subscribers as $subscriber) { | |
$output .= $subscriber['email'].$sep.$subscriber['firstname']."\n"; | |
} | |
header('Content-type: application/csv'); | |
header('Content-Disposition: attachment; filename='.$filename); | |
echo utf8_decode($output); | |
exit; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment