3 # This file generates what Excell refers to as "CSV" files. This format makes
4 # little sense, and does not actually have anything to do with commas.
6 # pass in a 2d array (array of rows) and it'll send it to the browser
7 function array2d_to_csv_download($data, $filename) {
8 header('Content-type: application/csv');
9 header('Content-Disposition: attachment; filename=' . $filename);
10 foreach($data as $row) {
11 foreach($row as $el) {
12 echo '"' . str_replace('"', '""', $el) . "\"\t";
14 echo "\n"; # apparently can be \n or \r\n