Save array to different columns with fputcsv

0

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.

    
asked by anonymous 09.10.2017 / 15:39

1 answer

2

Problem solved with addition of one; at the end of the fput.

fputcsv($out, $linha, ';');
    
09.10.2017 / 16:23