protected function format($data, $file_handle)
    {
        $header = false;
        foreach ($data as $idx => $row)
        {
            $row = WF::cast_array($row);
            $this->validateRow($row);

            if ($this->write_bom && ftell($file_handle) === 0)
                fwrite($file_handle, Encoding::getBOM('UTF8'));

            if (!$header && $this->write_header)
            {
                $keys = array_keys($row);
                fputcsv($file_handle, $keys, $this->delimiter, $this->enclosure, $this->escape_char);
                $header = true;
            }
            fputcsv($file_handle, $row, $this->delimiter, $this->enclosure, $this->escape_char);
        }
    }
protected function format($data, $file_handle)
    {
        $header = false;
        foreach ($data as $idx => $row)
        {
            $row = WF::cast_array($row);
            $this->validateRow($row);

            if ($this->write_bom && ftell($file_handle) === 0)
                fwrite($file_handle, Encoding::getBOM('UTF8'));

            if (!$header && $this->write_header)
            {
                $keys = array_keys($row);
                fputcsv($file_handle, $keys, $this->delimiter, $this->enclosure, $this->escape_char);
                $header = true;
            }
            fputcsv($file_handle, $row, $this->delimiter, $this->enclosure, $this->escape_char);
        }
    }
protected function format ( $ data , $ file_handle ) { $ header = false ; foreach ( $ data as $ idx => $ row ) { $ row = WF :: cast_array ( $ row ) ; $ this -> validateRow ( $ row ) ; if ( $ this -> write_bom && ftell ( $ file_handle ) === 0 ) fwrite ( $ file_handle , Encoding :: getBOM ( 'UTF8' ) ) ; if ( ! $ header && $ this -> write_header ) { $ keys = array_keys ( $ row ) ; fputcsv ( $ file_handle , $ keys , $ this -> delimiter , $ this -> enclosure , $ this -> escape_char ) ; $ header = true ; } fputcsv ( $ file_handle , $ row , $ this -> delimiter , $ this -> enclosure , $ this -> escape_char ) ; } }
Format the data into CSV
@param mixed $data Traversable data
Format the data into CSV