A quick utility library for working with CSV's
Fund package maintenance!
daniel-griffiths
Ko Fi
www.paypal.me/danielgriffithsdev
Installs: 8 632
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ~7.0
Requires (Dev)
- phpstan/phpstan: ^0.11
- phpunit/phpunit: ^8.3.5
This package is auto-updated.
Last update: 2025-01-25 15:53:42 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