我想将数组转换为 csv,我能够将关联数组转换为 csv。
但无法获得标题。
我希望 NUMBER TYPE DATE 作为标题动态
下面是我转换的数组。
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
)
)
代码如下。但无法获取标题,但它的值即将到来。
<?
$fp1 = fopen('file.csv', 'w');
foreach ($arr2 as $fields)
{
fputcsv($fp1, $fields);
}
fclose($fp1);
?>