This question already has an answer here:
I'm trying to generate a csv file with PHP array
If I did this
$fp = fopen('csv/languages.csv', 'w');
foreach ($final_new_array as $row) {
fputcsv($fp, $row);
}
fclose($fp);
I got the languages.csv generated, but when I open it up. I saw some fields have quotes some not.
See this image below.
I want to make sure to generate quotes for all the cells to be consistent, so I have tried.
$fp = fopen('csv/languages.csv', 'w');
foreach ($final_new_array as $row) {
fputcsv($fp, implode(',',array_walk($row, '"'.$row.'"')));
}
fclose($fp);
I kept getting error
Array to string conversion
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire