Properties

$data

$data : mixed

CSV data in PHP

Type

mixed

$string

$string : string

CSV string

Type

string

Methods

__construct()

__construct(mixed  $data = null) 

Constructor

Instantiate the Csv object.

Parameters

mixed $data

loadFile()

loadFile(string  $file, array  $options = array()) : self

Load CSV file

Parameters

string $file
array $options

Returns

self

loadString()

loadString(string  $string, array  $options = array()) : self

Load CSV string

Parameters

string $string
array $options

Returns

self

loadData()

loadData(array  $data, array  $options = array()) : self

Load CSV data

Parameters

array $data
array $options

Returns

self

getDataFromFile()

getDataFromFile(string  $file, array  $options = array()) : array

Load CSV file and get data

Parameters

string $file
array $options

Returns

array

writeDataToFile()

writeDataToFile(array  $data, string  $to, array  $options = array()) : void

Write data to file

Parameters

array $data
string $to
array $options

outputDataToHttp()

outputDataToHttp(array  $data, array  $options = array(), string  $filename = 'pop-data.csv', boolean  $forceDownload = true, array  $headers = array()) : void

Write data to file

Parameters

array $data
array $options
string $filename
boolean $forceDownload
array $headers

processOptions()

processOptions(array  $options) : array

Process CSV options

Parameters

array $options

Returns

array

serialize()

serialize(array  $options = array()) : string

Serialize the data to a CSV string

Parameters

array $options

Returns

string

unserialize()

unserialize(array  $options = array()) : mixed

Unserialize the string to data

Parameters

array $options

Returns

mixed

setData()

setData(array  $data) : \Pop\Csv\Csv

Set data

Parameters

array $data

Returns

\Pop\Csv\Csv

getData()

getData() : array

Get data

Returns

array

setString()

setString(string  $string) : \Pop\Csv\Csv

Set string

Parameters

string $string

Returns

\Pop\Csv\Csv

getString()

getString() : string

Get string

Returns

string

isSerialized()

isSerialized() : boolean

Check if data was serialized

Returns

boolean

isUnserialized()

isUnserialized() : boolean

Check if string was unserialized

Returns

boolean

outputToHttp()

outputToHttp(string  $filename = 'pop-data.csv', boolean  $forceDownload = true, array  $headers = array()) : void

Output CSV string data to HTTP

Parameters

string $filename
boolean $forceDownload
array $headers

writeToFile()

writeToFile(string  $to) : void

Output CSV data to a file

Parameters

string $to

appendDataToFile()

appendDataToFile(string  $file, array  $data, array  $options = array(), boolean  $validate = true) : void

Append additional CSV data to a pre-existing file

Parameters

string $file
array $data
array $options
boolean $validate

appendRowToFile()

appendRowToFile(string  $file, array  $row, array  $options = array(), boolean  $validate = true) : void

Append additional CSV row of data to a pre-existing file

Parameters

string $file
array $row
array $options
boolean $validate

serializeData()

serializeData(mixed  $data, array  $options = array()) : string

Convert the data into CSV format.

Parameters

mixed $data
array $options

Returns

string

unserializeString()

unserializeString(string  $string, array  $options = array()) : array

Parse the CSV string into a PHP array

Parameters

string $string
array $options

Returns

array

serializeRow()

serializeRow(array  $value, array  $omit = array(), string  $delimiter = ',', string  $enclosure = '"', string  $escape = '"', boolean  $newline = true, integer  $limit) : string

Serialize single row of data;

Parameters

array $value
array $omit
string $delimiter
string $enclosure
string $escape
boolean $newline
integer $limit

Returns

string

getFieldHeaders()

getFieldHeaders(mixed  $data, string  $delimiter = ',', array  $omit = array()) : string

Get field headers

Parameters

mixed $data
string $delimiter
array $omit

Returns

string

isValid()

isValid(string  $string) : boolean

Determine if the string is valid CSV

Parameters

string $string

Returns

boolean

__toString()

__toString() : string

Render CSV string data to string

Returns

string