henrikac / php-csv

Package that makes it easy to read and write data to csv files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

  1. Fork it (https://github.com/henrikac/php-csv/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

About

Package that makes it easy to read and write data to csv files

License:MIT License


Languages

Language:PHP 99.6%Language:Shell 0.4%