title: php fputcsv and enclosing fields
body: <p>I was just about to ask the same questions as the question aksed here.... <a href="https://stackoverflow.com/questions/2489553/forcing-fputcsv-to-use-enclosure-for-all-fields">Forcing fputcsv to Use Enclosure For *all* Fields</a></p>
  
  <p>The question was</p>
  
  <blockquote>
    <p>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.</p>
    
    <p>For example, you might end up with a
    line like this</p>
    
    <p>11,"Bob ",Jenkins,"200 main st. USA
    ",etc</p>
    
    <p>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?</p>
  </blockquote>
  
  <p>The answer was:</p>
  
  <blockquote>
    <p>No, fputcsv() only encloses the field
    under the following conditions</p>
  </blockquote>
  
  <pre><code>/* enclose a field that contains a delimiter, an enclosure character, or a newline */
  if (FPUTCSV_FLD_CHK(delimiter) ||
    FPUTCSV_FLD_CHK(enclosure) ||
    FPUTCSV_FLD_CHK(escape_char) ||
    FPUTCSV_FLD_CHK('\n') ||
    FPUTCSV_FLD_CHK('\r') ||
    FPUTCSV_FLD_CHK('\t') ||
    FPUTCSV_FLD_CHK(' ')
  )
  </code></pre>
  
  <blockquote>
    <p>There is no "always enclose" option.</p>
  </blockquote>
  
  <p>I need to create a CSV file will every field enclosed... What would be the best solution?</p>
  
  <p>Thanks in advance...</p>