mardi 7 février 2017

How to insert associative array into csv using thephpleague

I have used thephpleague library into laravel5.1 http://ift.tt/2knzyBP

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?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2jYOEPK
via IFTTT

Aucun commentaire:

Enregistrer un commentaire