Last active
June 14, 2016 18:33
-
-
Save roneigebert/ed58f663e48f084660c13d6b145dbc23 to your computer and use it in GitHub Desktop.
Php Csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Csv{ | |
private $output; | |
private $delimiter; | |
function __construct($file_name, $delimiter = ';'){ | |
$this->output = fopen('php://output', 'w'); | |
$this->delimiter = $delimiter; | |
header('Content-Type: text/csv; charset=utf-8'); | |
header('Content-Disposition: attachment; filename=' . $file_name); | |
} | |
function writeLine($data_array){ | |
fputcsv($this->output, $data_array, $this->delimiter); | |
} | |
function browserDownload(){ | |
fclose($this->output); | |
exit(0); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment