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 nothing is passed in for the enclosure param. Google is failing me (returning results for a whole bunch of pages about fputcsv
), and PEAR's libraries do more or less the same things as fputcsv
.
Something that works exactly like fputcsv
, but will allow the fields to remain unquoted.
currently: "field 1","field 2",field3hasNoSpaces
desired: field 1,field 2,field3hasNoSpaces
The warnings about foregoing enclosures are valid, but you've said they don't apply to your use-case.
I'm wondering why you can't just use something like this?
Figured it out. By passing in the ascii code for Null to the
car()
function it seems to work just fine.fputcsv($f, $array, $delimiter, car(0))
Thanks for the answers everyone!!!
chr(0)
also worked for me:works with chr() function:
fputcsv($file, $data, ';', chr(127));