Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $data = array();
- $stream = fopen("php://temp", 'w');
- foreach($data as $key => $val) {
- fputcsv($stream, $val);
- }
- rewind($stream);
- $data = stream_get_contents($stream);
- fclose($stream);
- header('Content-Description: File Transfer');
- header('Content-Type: text/csv');
- header('Content-Disposition: attachment; filename=data.csv');
- header('Expires: 0');
- header('Cache-Control: must-revalidate');
- header('Pragma: public');
- echo $data;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment