public function fromArray($array, $isList = false, $includeHeading = true)
    {
        $rows = array();
        if ($isList) {
            if ($includeHeading) {
                $rows[] = implode($this->formatRow(array_keys(reset($array))), $this->delimiter);
            }
            foreach ($array as $row) {
                $rows[] = implode($this->formatRow($row), $this->delimiter);
            }
        } else {
            if ($includeHeading) {
                $rows[] = implode($this->formatRow(array_keys($array)), $this->delimiter);
            }
            $rows[] = implode($this->formatRow($array), $this->delimiter);
        }

        return implode($rows, $this->lineTerminator) . $this->lineTerminator;
    }
public function fromArray($array, $isList = false, $includeHeading = true)
    {
        $rows = array();
        if ($isList) {
            if ($includeHeading) {
                $rows[] = implode($this->formatRow(array_keys(reset($array))), $this->delimiter);
            }
            foreach ($array as $row) {
                $rows[] = implode($this->formatRow($row), $this->delimiter);
            }
        } else {
            if ($includeHeading) {
                $rows[] = implode($this->formatRow(array_keys($array)), $this->delimiter);
            }
            $rows[] = implode($this->formatRow($array), $this->delimiter);
        }

        return implode($rows, $this->lineTerminator) . $this->lineTerminator;
    }
public function fromArray ( $ array , $ isList = false , $ includeHeading = true ) { $ rows = array ( ) ; if ( $ isList ) { if ( $ includeHeading ) { $ rows [ ] = implode ( $ this -> formatRow ( array_keys ( reset ( $ array ) ) ) , $ this -> delimiter ) ; } foreach ( $ array as $ row ) { $ rows [ ] = implode ( $ this -> formatRow ( $ row ) , $ this -> delimiter ) ; } } else { if ( $ includeHeading ) { $ rows [ ] = implode ( $ this -> formatRow ( array_keys ( $ array ) ) , $ this -> delimiter ) ; } $ rows [ ] = implode ( $ this -> formatRow ( $ array ) , $ this -> delimiter ) ; } return implode ( $ rows , $ this -> lineTerminator ) . $ this -> lineTerminator ; }
Converts data from an associative array to CSV.

@param array   $array          Source data to convert
@param boolean $isList         Whether the input data contains more than one row
@param boolean $includeHeading Whether the output should contain a heading line

@return string Converted data, as a CSV string
Converts data from an associative array to CSV .