PHP to csv semi-colon issue -
i have following $data
array:
array( (int) 0 => '37899810;214214;01;5083;;', (int) 1 => '37899810;214215;01;19966;;', (int) 2 => '37899810;54654;01;35691;;', (int) 3 => '37899810;769;01;52016;;' )
when try echo csv in following way:
foreach($data $row): echo $row."\n"; endforeach;
for each , every row, semi-colons escaped , integers put different cells. want instead, whole string, let's 37899810;214214;01;5083;;
placed in 1 cell, , remaining ones placed in other rows, strings take 1 cell.
try this
header( 'content-type: text/csv' ); header( 'content-disposition: attachment;filename=example.csv'); $handle = fopen('php://output', 'r+'); foreach ($data $row) { fputcsv($handle, $row, ';'); } fclose($handle);
Comments
Post a Comment