I want to convert array to csv ,im able to convert the associative array to csv.
But not able to get the headers.
I want the NUMBER TYPE DATE as headers dynamically
Below is the array i converrted .
Array
(
[0] => Array
(
[NUMBER] => 67
[TYPE] => Other
[DATE] => 3/31/2011
)
[1] => Array
(
[NUMBER] => 87
[TYPE] => something
[DATE] => 3/28/2011
)
[2] => Array
(
[NUMBER] => 67
[TYPE] => Other
[DATE] => 3/2/2011
)
)
The code is given below .But not able to get the headers but its values are coming.
<?
$fp1 = fopen('file.csv', 'w');
foreach ($arr2 as $fields)
{
fputcsv($fp1, $fields);
}
fclose($fp1);
?>
array_keys
function at the beginning to put in the headers. – Jon May 3 at 20:09