0
I am trying to output some data from BD to csv with the following code:
while($linha=$buscar->fetch(PDO::FETCH_ASSOC)){
fputcsv($out, $linha);
}
fclose( $out );
}
which returns all the contents of the array in a single column. How could I get each position of the array to be in a column in csv?
OBS:
print_r($linha);
results in :
Array
(
[data] => 20/05/2017
[descricao] => pag
[pagamento] => 500
)
Where they all stay in the same column in csv, and in case the ideal would be for each one to stay in a column.
Could put the result of
print_r($linha);
in the question?– rray
Sorry, I did not understand very well, I must put in the code posted here?
– Wel
That, edit the question and put the result. Your code seems correct I just don’t understand how everything looks in one column.
– rray
the code is really correct, it does what I intend, but I would like a code "more" to organize it by columns, because the one I presented creates a row per loop in csv, but does not create a column per array, which in this case is what I want.
– Wel
Add Problem Solution as Answer, not Question Editing.
– Don't Panic