I am trying to export into csv file. Here excel sheet insertion not correct. Only 3 rows inserted and it is not only in correct format also (some times 3 rows are inserted to one cell). Please help, what is the reason for that?
$row is a multidimensional array as follows :-
Array
(
[0] => Array
(
[0] => 1
[1] => East Midlands
[2] => East Midlands Equestrian
)
[1] => Array
(
[0] => 2
[1] => East Midlands
[2] => Leicester City
)
)
The code used to insert into csv is :-
$fp = fopen('/home/test/workspace/example/sites/default/files/csv/all.csv', 'w');
$header = array('#', 'Region', 'Club Name', 'Position', 'First Name', 'Last Name', 'Address 1', 'Address 2', 'City', 'County', 'Post Code', 'Phone', 'Mobile', 'Email', 'Fax');
fputcsv($fp, $header);
foreach ($rows as $row) { //$row is 2D array shown above
fputcsv($fp, $row);
}
fclose($fp);