Forcing fputcsv to Use Enclosure For *all* Fields

Posted by Alan Storm on Stack Overflow See other posts from Stack Overflow or by Alan Storm
Published on 2010-03-22T01:30:41Z Indexed on 2010/03/22 1:31 UTC
Read the original article Hit count: 552

Filed under:
|
|

When I use fputcsv to write out a line to an open file handle, PHP will add an enclosing character to any column that it believes needs it, but will leave other columns without the enclosures.

For example, you might end up with a line like this

11,"Bob ",Jenkins,"200 main st. USA ",etc

Short of appending a bogus space to the end of every field, is there any way to force fputcsv to always enclose columns with the enclosure (defaults to a ") character?

© Stack Overflow or respective owner

Related posts about php

Related posts about fputcsv