PHP Classes

PHP CSV Export Download: Export array data to a CVS file to be downloaded

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 130 All time: 9,364 This week: 206Up
Version License PHP version Categories
php-csv-export 1.0Custom (specified...5PHP 5, Files and Folders
Description 

Author

This package can export array data to a CVS file to be downloaded.

It can take an array of data to be exported and generates a CSV file that is served for download as a file with a given name.

The CSV file name and the CSV column header names are configurable parameters.

Picture of Hashemi Rafsan
  Performance   Level  
Name: Hashemi Rafsan <contact>
Classes: 7 packages by
Country: Bangladesh Bangladesh
Innovation award
Innovation award
Nominee: 1x

Documentation

PHP CSV Export

A simple & lightweight csv export package for PHP

Installation

You can start it from composer. Go to your terminal and run this command from your project root directory.

composer require hashemi/php-csv-export

Usage

After Complete installation, It's time to check how to use.

<?php

require_once __DIR__ . '/vendor/autoload.php';

use Hashemi\CsvExport\CsvExport;

$headers = [
    'id',
    'name',
    'age'
];

$rows = [
    [1, 'Foo', 12],
    [2, 'Bar', 34],
    [3, 'John', 12]
];

(new CsvExport())
    ->setHeaders($headers)
    ->setRows($rows)
    ->setFileName('employee.csv')
    ->download();

// or

(new CsvExport($headers, $rows, 'employee.csv'))->download();

Contributing

Pull requests are welcome. For any changes, please open an issue first to discuss what you would like to change.


  Files folder image Files (4)  
File Role Description
Files folder imagesrc (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files (4)  /  src  
File Role Description
  Plain text file CsvExport.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:130
This week:0
All time:9,364
This week:206Up