I am generating csv file using fputcsv function. The problem is that I need something like this:
110,"","","60114010100000453237001004","some string"
The code:
for($i = 0; $i < count($list); $i++)
{
$input[$i][] = 110;
$input[$i][] = "";
$input[$i][] = "";
$input[$i][] = "60114010100000453237001004";
$input[$i][] = "some string";
}
$handler = fopen($fileName, 'w+');
foreach($input as $fields)
{
fputcsv($handler, $fields);
}
fclose($handler);
And the output is:
110,,,60114010100000453237001004,"some string"
So there are some quotes missing. When I try to add quotes myself, I get doubled quotes like:
110,"""","""","""60114010100000453237001004""","some string"
This happen when the code is like:
$input[$i][] = '"' . "" . '"';
or:
$input[$i][] = '"' . "6011..." . '"';
I tried setting enclosure parameter as an empty string, but that's not allowed.
How can I solve this problem?