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 # I can't figure out how to get multi-line fields to work, so replace newlines with 4 spaces.
8 function array2d_to_csv_download($data, $filename) {
9 header('Content-type: application/csv');
10 header('Content-Disposition: attachment; filename=' . $filename);
11 foreach($data as $row) {
13 foreach($row as $el) {
19 echo '"' . str_replace("\n", " ", str_replace('"', '""', $el)) . '"';