ARRAY_FORMAT
ARRAY_FORMAT
Array output format
Format class Help convert between various formats such as XML, JSON, CSV, etc.
factory(mixed $data, string $from_type = NULL) : object
Create an instance of the format class e.g: echo $this->format->factory(['foo' => 'bar'])->to_csv();
mixed | $data | Data to convert/parse |
string | $from_type | Type to convert from e.g. json, csv, html |
Instance of the format class
to_csv(mixed|NULL $data = NULL, string $delimiter = ',', string $enclosure = '"') : string
mixed|NULL | $data | Optional data to pass, so as to override the data passed to the constructor |
string | $delimiter | The optional delimiter parameter sets the field delimiter (one character only). NULL will use the default value (,) |
string | $enclosure | The optional enclosure parameter sets the field enclosure (one character only). NULL will use the default value (") |
A csv string
_from_csv(string $data, string $delimiter = ',', string $enclosure = '"') : array
string | $data | CSV string |
string | $delimiter | The optional delimiter parameter sets the field delimiter (one character only). NULL will use the default value (,) |
string | $enclosure | The optional enclosure parameter sets the field enclosure (one character only). NULL will use the default value (") |
A multi-dimensional array with the outer array being the number of rows and the inner arrays the individual fields