zebba/loader

Zebba Loader Component

Installs: 101

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:component

1.0.5 2015-01-22 09:24 UTC

This package is auto-updated.

Last update: 2024-04-09 06:42:54 UTC


README

Installation

Modify your composer.json:

{
    "require" : {
        "zebba/loader" : "1.*"
    }
}    

Usage

Parsing CSV files

<?php

$csv = "key1;key2\r\nvalue1;2\r\nvalue2;3";

// $csv = new \SplFileInfo(...);

try {
	$output = Csv::parse($csv);
} catch (\Zebba\Component\Loader\Exception\ParseException $e) {
	throw $e;
}	

/*
 * $output = array(
 * 	array(
 *		'key1' => 'value1',
 *      'key2' => 2,
 *	), array(
 *   	key1' => 'value2',
 *      'key2' => 3,
 *	)
 * );
*/

Dumping arrays to CSV files

<?php

<?php

$input = array(
	array(
    	'key1' => 'value1',
        'key2' => 2,
	), array(
    	'key1' => 'value2',
        'key2' => 3,
	)
);

$csv = Csv::dump($input);

// $csv = "key1;key2\r\nvalue1;2\r\nvalue2;3";