Properties

$data

$data : mixed

CSV data in PHP

Type

mixed

$string

$string : string

CSV string

Type

string

Methods

__construct()

__construct(mixed  $data) 

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

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

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

getData()

getData() : array

Get data

Returns

array

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

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 = "\\") : string

Serialize single row of data;

Parameters

array $value
array $omit
string $delimiter
string $enclosure
string $escape

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