I am trying to create a CSV file like this:
Name surname
disha goyal
Code goes like this:
<?php
$fp = fopen('filse.csv', 'w');
fwrite($fp, 'Name');
fwrite($fp, "\t");
fwrite($fp, "Surname");
fwrite($fp, "\n");
fwrite($fp, 'disha');
fwrite($fp, "\t");
fwrite($fp, 'goyal');
fclose($fp);
?>`
Output is this:
Namesurname
dishagoyal
While opening the document in Excel, you must specify that the delimiter you use is tab.
By default, a csv file is assumed to be comma separated.
You can also use comma instead of tab for proper output without any settings.