I'm trying to output some data from DB to csv with the following code:
while($linha=$buscar->fetch(PDO::FETCH_ASSOC)){
fputcsv($out, $linha);
}
fclose( $out );
}
which returns the entire contents of the array in a single column. How could I make each array position to be in a column in csv?
OBS:
print_r($linha);
results in:
Array
(
[data] => 20/05/2017
[descricao] => pag
[pagamento] => 500
)
Where all are in the same column in the csv, and in the case the ideal would be that each one stayed in a column.