A quick utility library for working with CSV's
v1.1.0
2021-05-27 15:46 UTC
Requires
- php: ~7.0
Requires (Dev)
- phpstan/phpstan: ^0.11
- phpunit/phpunit: ^8.3.5
This package is auto-updated.
Last update: 2026-02-25 18:12:31 UTC
README
A quick utility library for working with CSV's in PHP. See /tests for examples.
Installation
composer require daniel-griffiths/csv dev-master
Usage
<?php require __DIR__.'/vendor/autoload.php'; use DanielGriffiths\CSV; // Convert a CSV file to a array $rows = CSV::fromFile(__DIR__.'/file.csv'); // Convert an array to a CSV string $csvString = CSV::fromArray([ [ 'animal' => 'Dog', 'name' => 'Patch', ] ])->toString(); // Convert an array to a CSV and download it CSV::fromArray([ [ 'animal' => 'Dog', 'name' => 'Patch', ] ])->download('file.csv'); // Convert an array to a CSV and write it to a file CSV::fromArray([ [ 'animal' => 'Dog', 'name' => 'Patch', ] ])->toFile('file.csv');
Tests
./vendor/bin/phpunit