I have used thephpleague library into laravel5.1 http://csv.thephpleague.com/inserting/
I want an example to add associative array into CSV. Right now I have used this functions insertOne($array) for header of CSV and insertAll($array) for their column values.
My code is -
$path = public_path().'/csv/'.$filename;
$csv = Writer::createFromPath(new \SplFileObject($path, 'w+'), 'a+');
$csv->insertOne($headers);
$csv->insertAll($data);
$csv->output($path);
my $data array has an associative array (array inside the array) but insertAll() method gives me an error if $data has an associative array.
Please let me know how to deal with associative arrya?