![]() ![]() |
Info | ![]() |
![]() |
![]() ![]() |
Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2015-05-02 (1 year ago) ![]() | Not enough user ratings | Total: 160 | All time: 8,109 This week: 961![]() |
Version | License | PHP version | Categories | |||
csv-to-arrays 2.0.1 | MIT/X Consortium ... | 5.3.0 | PHP 5, Files and Folders, Parsers |
Description | Author | |||||||||||||
This class can parse CSV data to indexed or associative arrays. |
|
PHP client to parse CSV data from a file, stream or string into indexed or associative arrays.
Install using composer
#composer.json
{
"require": {
"jabranr/csv-parser": ">=1.0.0"
}
}
Run following to install
$ comsposer install
Initiate a new instance
$csv = new CSV_Parser();
Get data from a string
/@param: string $str/
$csv->fromString( $str );
Get data from a stream
/@param: stream $stream (e.g. php://input)/
$csv->fromStream( $stream );
Get data from a file
/@param: file $file/
$csv->fromFile( $file );
Parse data for output
/
* Set $headers true/false to include top/first row
* and output an associative array
*
* @param: boolean $headers (Default: true)
* @return: array
*/
$csv->parse( $headers );
Example input string
$str = 'id,first_name,last_name;1,Jabran,Rafique';
$csv->fromString( $str );
// Output with headers:
$csv->parse();
Array(
[id] => 1,
[first_name] => 'Jabran',
[last_name] => 'Rafique'
)
// Output without headers:
$csv->parse( false );
Array(
[0] => array(
[0] => 'id',
[1] => 'first_name',
[2] => 'last_name'
),
[1] => array(
[0] => 1,
[1] => 'Jabran',
[2] => 'Rafique'
)
)
© 2015 MIT License - Jabran Rafique
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
||||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Aux. | Configuration script | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Doc. | Auxiliary data |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.