Is there a native function or solid class/library for writing an array as a line in a CSV file without enclosures? fputcsv
will default to \"
if no
<?php
$filename = "sample.csv";
$handle = fopen($filename, 'w+');
fputcsv($handle, ['column 1','column 2']);
$data = ['sample','data'];
fputs($handle, implode($data,',')."\n");
// or
fwrite($handle, implode($data,',')."\n");
fclose($handle);
$headers = array(
'Content-Type' => 'text/csv',
);
chr(0)
also worked for me:
fputcsv($fp, $aLine, $sDelimiter, chr(0));