1. Go to this page and download the library: Download mnshankar/csv library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$arr = User::all()->toArray(); //use eloquent to get array of all users in 'users' table
return CSV::with($arr)->put(storage_path().'/downloads/myusers.csv'); //store as csv in this path
return CSV::fromArray($arr)->render(); //download as csv
return CSV::fromFile(storage_path().'/downloads/my.csv')->toArray(); //return csv file as an array
return CSV::fromFile(storage_path().'/downloads/my.csv')->render('abc.csv'); //render saved csv file as a downloadable document
return CSV::with(storage_path().'/downloads/my.csv')->render('abc.csv'); //use 'with'.. same as previous
$arr = array(
array('col1'=>'a','col2'=>'b'),
array('col1'=>'1','col2'=>'2'),
array('col1'=>'3','col2'=>'4'),
);
return $csvObj->fromArray($arr)->render('myfile.csv'); //download as csv;
return $csvObj->fromArray($arr)->withSeparator()->render('myfile.csv'); //add delimiter for better excel compatibility & download
return $csvObj->with($arr)->put('/downloads/myusers.csv'); //store as csv in this path
return $csvObj->fromFile('/downloads/my.csv')->toArray(); //return csv file as an array
return $csvObj->fromFile('/downloads/my.csv')->render('abc.csv'); //render saved csv file as a downloadable document
return $csvObj->with('/downloads/my.csv')->render('abc.csv'); //use 'with'.. same as previous
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.