Wrap CSV values generated by PHP fputcsv() with “ ”

ddtnjzk

New Member
So, my code generates a CSV file using PHP's built-in \[code\]fputcsv\[/code\] function.For the delimiter, I use \[code\]','\[/code\] (a comma).
For the enclosure, I use \[code\]'"'\[/code\] (a double-quote).However, when I try something like \[code\]fputcsv($file,array('a','b',"long string, with commas",NULL,''),',','"');\[/code\]it outputs\[code\]a,b,"long string, with commas",,\[/code\]but I would like it to output\[code\]"a","b","long string, with commas","",""\[/code\]Is there an easy way to deal with this, or would I have to write a replacement for \[code\]fputcsv\[/code\]?
 
Back
Top