mirror of
https://github.com/parsecsv/parsecsv-for-php.git
synced 2026-02-19 08:36:39 +00:00
output readability
This commit is contained in:
@@ -278,14 +278,22 @@ class parseCSV {
|
|||||||
* @return CSV data using delimiter of choice, or default
|
* @return CSV data using delimiter of choice, or default
|
||||||
*/
|
*/
|
||||||
function output ($filename = null, $data = array(), $fields = array(), $delimiter = null) {
|
function output ($filename = null, $data = array(), $fields = array(), $delimiter = null) {
|
||||||
if ( empty($filename) ) $filename = $this->output_filename;
|
if (empty($filename)) {
|
||||||
if ( $delimiter === null ) $delimiter = $this->output_delimiter;
|
$filename = $this->output_filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($delimiter===null) {
|
||||||
|
$delimiter = $this->output_delimiter;
|
||||||
|
}
|
||||||
|
|
||||||
$data = $this->unparse($data, $fields, null, null, $delimiter);
|
$data = $this->unparse($data, $fields, null, null, $delimiter);
|
||||||
if ( $filename !== null ) {
|
|
||||||
|
if ($filename!==null) {
|
||||||
header('Content-type: application/csv');
|
header('Content-type: application/csv');
|
||||||
header('Content-Disposition: attachment; filename="'.$filename.'"');
|
header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||||
echo $data;
|
echo $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user