Properties

$filters

$filters : array<mixed,resource>

Attached filters.

Type

array<mixed,resource>

$stream

$stream : resource

stream resource.

Type

resource

$should_close_stream

$should_close_stream : boolean

Tell whether the stream should be closed on object destruction.

Type

boolean

$value

$value : mixed

Current iterator value.

Type

mixed

$offset

$offset : integer

Current iterator key.

Type

integer

$flags

$flags : integer

Flags for the Document.

Type

integer

$delimiter

$delimiter : string

the field delimiter (one character only).

Type

string

$enclosure

$enclosure : string

the field enclosure character (one character only).

Type

string

$escape

$escape : string

the field escape character (one character only).

Type

string

$is_seekable

$is_seekable : boolean

Tell whether the current stream is seekable;.

Type

boolean

Methods

__construct()

__construct(resource  $stream) 

New instance.

Parameters

resource $stream

stream type resource

__destruct()

__destruct() 

{@inheritdoc}

__clone()

__clone() 

{@inheritdoc}

__debugInfo()

__debugInfo() 

{@inheritdoc}

createFromPath()

createFromPath(\League\Csv\string  $path, \League\Csv\string  $open_mode = 'r', resource|null  $context = null) : static

Return a new instance from a file path.

Parameters

\League\Csv\string $path
\League\Csv\string $open_mode
resource|null $context

Throws

\League\Csv\Exception

if the stream resource can not be created

Returns

static

createFromString()

createFromString(\League\Csv\string  $content = '') : static

Return a new instance from a string.

Parameters

\League\Csv\string $content

Returns

static

getPathname()

getPathname() 

Return the URI of the underlying stream.

appendFilter()

appendFilter(\League\Csv\string  $filtername, \League\Csv\int  $read_write, null|mixed  $params = null) 

append a filter.

Parameters

\League\Csv\string $filtername
\League\Csv\int $read_write
null|mixed $params

Throws

\League\Csv\Exception

if the filter can not be appended

setCsvControl()

setCsvControl(\League\Csv\string  $delimiter = ',', \League\Csv\string  $enclosure = '"', \League\Csv\string  $escape = '\\') 

Set CSV control.

Parameters

\League\Csv\string $delimiter
\League\Csv\string $enclosure
\League\Csv\string $escape

getCsvControl()

getCsvControl() : array<mixed,string>

Set CSV control.

Returns

array<mixed,string>

setFlags()

setFlags(\League\Csv\int  $flags) 

Set CSV stream flags.

Parameters

\League\Csv\int $flags

fputcsv()

fputcsv(array  $fields, \League\Csv\string  $delimiter = ',', \League\Csv\string  $enclosure = '"', \League\Csv\string  $escape = '\\') : integer|false

Write a field array as a CSV line.

Parameters

array $fields
\League\Csv\string $delimiter
\League\Csv\string $enclosure
\League\Csv\string $escape

Returns

integer|false

key()

key() : integer

Get line number.

Returns

integer

next()

next() 

Read next line.

rewind()

rewind() 

Rewind the file to the first line.

Throws

\League\Csv\Exception

if the stream resource is not seekable

valid()

valid() : boolean

Not at EOF.

Returns

boolean

current()

current() 

Retrieves the current line of the file.

seek()

seek(integer  $position) 

Seek to specified line.

Parameters

integer $position

Throws

\League\Csv\Exception

if the position is negative

fpassthru()

fpassthru() : integer

Output all remaining data on a file pointer.

Returns

integer

fread()

fread(integer  $length) : string|false

Read from file.

Parameters

integer $length

The number of bytes to read

Returns

string|false

fgets()

fgets() : string|false

Gets a line from file.

Returns

string|false

fseek()

fseek(\League\Csv\int  $offset, \League\Csv\int  $whence = \SEEK_SET) : integer

Seek to a position.

Parameters

\League\Csv\int $offset
\League\Csv\int $whence

Throws

\League\Csv\Exception

if the stream resource is not seekable

Returns

integer

fwrite()

fwrite(\League\Csv\string  $str, \League\Csv\int  $length = null) : integer|false

Write to stream.

Parameters

\League\Csv\string $str
\League\Csv\int $length

Returns

integer|false

fflush()

fflush() : boolean

Flushes the output to a file.

Returns

boolean

filterControl()

filterControl(\League\Csv\string  $delimiter, \League\Csv\string  $enclosure, \League\Csv\string  $escape, \League\Csv\string  $caller) 

Filter Csv control characters.

Parameters

\League\Csv\string $delimiter
\League\Csv\string $enclosure
\League\Csv\string $escape
\League\Csv\string $caller

Throws

\League\Csv\Exception

If the Csv control character is not one character only.

getCurrentRecord()

getCurrentRecord() : array|false

Retrieves the current line as a CSV Record.

Returns

array|false