public function fetchColumn($index = 0): Generator
    {
        $offset = $this->getColumnIndex($index, __METHOD__.'() expects the column index to be a valid string or integer, `%s` given');
        $filter = static function (array $record) use ($offset): bool {
            return isset($record[$offset]);
        };

        $select = static function (array $record) use ($offset): string {
            return $record[$offset];
        };

        $iterator = new MapIterator(new CallbackFilterIterator($this->records, $filter), $select);
        foreach ($iterator as $offset => $value) {
            yield $offset => $value;
        }
    }
public function fetchColumn($index = 0): Generator
    {
        $offset = $this->getColumnIndex($index, __METHOD__.'() expects the column index to be a valid string or integer, `%s` given');
        $filter = static function (array $record) use ($offset): bool {
            return isset($record[$offset]);
        };

        $select = static function (array $record) use ($offset): string {
            return $record[$offset];
        };

        $iterator = new MapIterator(new CallbackFilterIterator($this->records, $filter), $select);
        foreach ($iterator as $offset => $value) {
            yield $offset => $value;
        }
    }
public function fetchColumn ( $ index = 0 ) : Generator { $ offset = $ this -> getColumnIndex ( $ index , __METHOD__ . '() expects the column index to be a valid string or integer, `%s` given' ) ; $ filter = static function ( array $ record ) use ( $ offset ) : bool { return isset ( $ record [ $ offset ] ) ; } ; $ select = static function ( array $ record ) use ( $ offset ) : string { return $ record [ $ offset ] ; } ; $ iterator = new MapIterator ( new CallbackFilterIterator ( $ this -> records , $ filter ) , $ select ) ; foreach ( $ iterator as $ offset => $ value ) { yield $ offset => $ value ; } }
Returns a single column from the next record of the result set.

By default if no value is supplied the first column is fetch

@param string|int $index CSV column index
Returns a single column from the next record of the result set .