src/Csv.php
public function output($filename = null, $data = array(), $fields = array(), $delimiter = null) {
        if (empty($filename)) {
            $filename = $this->output_filename;
        }

        if ($delimiter === null) {
            $delimiter = $this->output_delimiter;
        }

        $flat_string = $this->unparse($data, $fields, null, null, $delimiter);

        if (!is_null($filename)) {
            $mime = $delimiter === "\t" ?
                'text/tab-separated-values' :
                'application/csv';
            header('Content-type: ' . $mime);
            header('Content-Length: ' . strlen($flat_string));
            header('Cache-Control: no-cache, must-revalidate');
            header('Pragma: no-cache');
            header('Expires: 0');
            header('Content-Disposition: attachment; filename="' . $filename . '"; modification-date="' . date('r') . '";');

            echo $flat_string;
        }

        return $flat_string;
    }
public function output($filename = null, $data = array(), $fields = array(), $delimiter = null) {
        if (empty($filename)) {
            $filename = $this->output_filename;
        }

        if ($delimiter === null) {
            $delimiter = $this->output_delimiter;
        }

        $flat_string = $this->unparse($data, $fields, null, null, $delimiter);

        if (!is_null($filename)) {
            $mime = $delimiter === "\t" ?
                'text/tab-separated-values' :
                'application/csv';
            header('Content-type: ' . $mime);
            header('Content-Length: ' . strlen($flat_string));
            header('Cache-Control: no-cache, must-revalidate');
            header('Pragma: no-cache');
            header('Expires: 0');
            header('Content-Disposition: attachment; filename="' . $filename . '"; modification-date="' . date('r') . '";');

            echo $flat_string;
        }

        return $flat_string;
    }
public function output ( $ filename = null , $ data = array ( ) , $ fields = array ( ) , $ delimiter = null ) { if ( empty ( $ filename ) ) { $ filename = $ this -> output_filename ; } if ( $ delimiter === null ) { $ delimiter = $ this -> output_delimiter ; } $ flat_string = $ this -> unparse ( $ data , $ fields , null , null , $ delimiter ) ; if ( ! is_null ( $ filename ) ) { $ mime = $ delimiter === "\t" ? 'text/tab-separated-values' : 'application/csv' ; header ( 'Content-type: ' . $ mime ) ; header ( 'Content-Length: ' . strlen ( $ flat_string ) ) ; header ( 'Cache-Control: no-cache, must-revalidate' ) ; header ( 'Pragma: no-cache' ) ; header ( 'Expires: 0' ) ; header ( 'Content-Disposition: attachment; filename="' . $ filename . '"; modification-date="' . date ( 'r' ) . '";' ) ; echo $ flat_string ; } return $ flat_string ; }
Output
Generate a CSV based string for output.

@param  string|null $filename   If a filename is specified here or in the
object, headers and data will be output
directly to browser as a downloadable
file. This file doesn't have to exist on
the server; the parameter only affects
how the download is called to the
browser.
@param  array[]     $data       2D array with data
@param  array       $fields     Field names
@param  string|null $delimiter  character used to separate data

@return string  The resulting CSV string
Output Generate a CSV based string for output .