When I want to put data in a CSV/Excel file it will automatically put all data in one column. This isn't very clear to read and I would like to have a single column for each data. Here is my code:
<?php
$data = array(
'aaa,bbb,ccc,dddd',
'123,456,789',
'"aaa","bbb"'
);
$fp = fopen('test.csv', 'w');
foreach ( $data as $line ) {
$val = explode(",", $line);
fputcsv($fp, $val);
}
fclose($fp);
?>
and this is what it is showing inside the CSV/excel file:
How it is now:

And here is how it should be:
