Menu
Building CSV with array. I don't use CodeIgniter's file download helper, so I can't help you on that front. Share| improve this answer. Edited Jun 4 '12 at 20:16.
If you need to download a CSV file on the fly without writing to external file, than you need to open php://output stream and use fputcsv on it. Built in fputcsv will generate CSV lines from given array, so you will have to loop over and collect the lines. And you need to use some special headers, those headers tell to the browser that the content you are going to send must be downloaded instead, as displayed on the browser as a regular HTML.
![Codeigniter Array To Csv File Codeigniter Array To Csv File](/uploads/1/2/4/2/124252788/257997851.png)
Below is the simple function which will generate and output the CSV file on the fly.