это сработает ...
<?php
function arrayToCsv($data, $fileName)
{
$fp = fopen($fileName, 'w');
foreach ($data as $fields) {
fputcsv($fp, $fields);
}
fclose($fp);
}
$failedRecordArray = array(array('col1','col2','col3','col4'), array('This','is','a','test'));
$failedRecordArrayFile = arrayToCsv($failedRecordArray, "file101.csv");
?>
file101.csv
col1,col2,col3,col4
This,is,a,test