php-csv
Package that makes it easy to read and write data to csv files.
Usage
Basic usage
<?php
$data = array(
array("1", "Alice", "23"),
array("2", "Bob", "42"),
array("3", "Eve", "8")
);
$csv = new CSV\CSV();
$csv->setHeaders(array("id", "name", "age"));
$csv->addRows($data);
foreach ($csv as $row) {
echo $row;
}
$csv[1]; // => CSV\Row("2", "Bob", "42")
count($csv); // => 3
$csv[] = array("4", "John", "89");
count($csv); // => 4
$csv->write("my-csv-file");
Contributing
- Fork it (https://github.com/henrikac/php-csv/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Henrik Christensen - creator and maintainer