1<?php
2header('Content-Type: text/csv');
3header('Content-Disposition: attachment; filename="sample.csv"');
4
5$list = array (
6 array('aaa', 'bbb', 'ccc', 'dddd'),
7 array('123', '456', '789'),
8 array('"aaa"', '"bbb"')
9);
10
11
12$fp = fopen('php://output', 'w');
13
14foreach ($list as $fields) {
15 fputcsv($fp, $fields);
16}
17
18fclose($fp);
19?>