I am generating a CSV downloadable file in PHP. I have a problem that when I open file in MS Excell or Ubuntu Libre Office the formate is not like what is expected.
I want this output but I can not force to start from new line.
Name Slope Length Size(Inches) Max Length Location
Name1 5 150 12" 500 location1
Name2 8 350 12" 400 location 2
Name3 16 326 12" 400 location3
This is my PHP code
$csv_data[] = $_POST['name'][$i];
$csv_data[] = $_POST['slope'][$i];
$csv_data[] = $_POST['length'][$i];
$csv_data[] = $size;
$csv_data[] = $max_length;
$csv_data[] = $_POST['location'][$i].PHP_EOLE;
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=file.csv');
$output = fopen('php://output', 'w');
fputcsv($output, array("Name", "Slope", "Length", "Size", "Max Length", "Location"));
fputcsv($output, $csv_data);
But this code output like this:
Name Slope Length Size Max Slope Length Location
Name1 5 150 12" 500 location1 Name2 8 350 12" 400 location 2 Name3 16 326 12" 400 location3