I would like to create a CSV document with a tab delimiter. I've tried a lot of things and searched all over the internet but there isn't a single site with a working solutions. This is the script I'm using right now, but it is exporting without a tab delimiter
$data[] = array("item 1", "item 2");
$data[] = array("item 3", "item 4");
$export = fopen("/export/test.csv", "w");
foreach ($data as $row) {
fputcsv($export, $row, "\t");
}
fclose($export);
I've also tried different other things instead of \t
like chr(9)
but nothing worked. Any solutions for this problem?
Was searching for a solution to the same problem. Saw the solution in the comments by Mark Baker
Use fwrite($export, "sep=\t".PHP_EOL);
before writing any contents to the file.