public function toArray($data, $rootKey = null, $isList = false, $includeHeading = true)
    {
        $rows = explode($this->lineTerminator, $data);
        if ($includeHeading) {
            $heading = array_shift($rows);
            $keys = explode($this->delimiter, $heading);
        } else {
            $keys = range(0, count($this->getColumns($rows[0])) - 1);
        }
        if ($isList) {
            $array = [];
            foreach ($rows as $row) {
                $values = $this->cleanupRow($this->getColumns($row));
                if ($values !== []) {
                    $array []= array_combine($keys, $values);
                }
            }
        } else {
            $values = $this->cleanupRow($this->getColumns(array_shift($rows)));
            if ($keys === [''] && $values === []) {
                $array = [];
            } else {
                if (count($keys) > count($values)) {
                    // empty values at the end of the row are not match bu the getColumns() regexp
                    $values = array_pad($values, count($keys), null);
                }
                $array = array_combine($keys, $values);
            }
        }

        return $array;
    }
public function toArray($data, $rootKey = null, $isList = false, $includeHeading = true)
    {
        $rows = explode($this->lineTerminator, $data);
        if ($includeHeading) {
            $heading = array_shift($rows);
            $keys = explode($this->delimiter, $heading);
        } else {
            $keys = range(0, count($this->getColumns($rows[0])) - 1);
        }
        if ($isList) {
            $array = [];
            foreach ($rows as $row) {
                $values = $this->cleanupRow($this->getColumns($row));
                if ($values !== []) {
                    $array []= array_combine($keys, $values);
                }
            }
        } else {
            $values = $this->cleanupRow($this->getColumns(array_shift($rows)));
            if ($keys === [''] && $values === []) {
                $array = [];
            } else {
                if (count($keys) > count($values)) {
                    // empty values at the end of the row are not match bu the getColumns() regexp
                    $values = array_pad($values, count($keys), null);
                }
                $array = array_combine($keys, $values);
            }
        }

        return $array;
    }
public function toArray ( $ data , $ rootKey = null , $ isList = false , $ includeHeading = true ) { $ rows = explode ( $ this -> lineTerminator , $ data ) ; if ( $ includeHeading ) { $ heading = array_shift ( $ rows ) ; $ keys = explode ( $ this -> delimiter , $ heading ) ; } else { $ keys = range ( 0 , count ( $ this -> getColumns ( $ rows [ 0 ] ) ) - 1 ) ; } if ( $ isList ) { $ array = [ ] ; foreach ( $ rows as $ row ) { $ values = $ this -> cleanupRow ( $ this -> getColumns ( $ row ) ) ; if ( $ values !== [ ] ) { $ array [ ] = array_combine ( $ keys , $ values ) ; } } } else { $ values = $ this -> cleanupRow ( $ this -> getColumns ( array_shift ( $ rows ) ) ) ; if ( $ keys === [ '' ] && $ values === [ ] ) { $ array = [ ] ; } else { if ( count ( $ keys ) > count ( $ values ) ) { // empty values at the end of the row are not match bu the getColumns() regexp $ values = array_pad ( $ values , count ( $ keys ) , null ) ; } $ array = array_combine ( $ keys , $ values ) ; } } return $ array ; }
Converts data from CSV to an associative array.

@param string $data Source data to convert, as a CSV string
@param string|null $rootKey Will not be used for converting because csv is flat
@param boolean $isList Whether the input data contains more than one row
@param boolean $includeHeading Whether the input contains a heading line

@return array Converted data
Converts data from CSV to an associative array .