Forcing fputcsv to Use Enclosure For *all* Fields

后端 未结 5 1928
星月不相逢
星月不相逢 2020-11-29 11:44

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 with

5条回答
  •  借酒劲吻你
    2020-11-29 12:43

    No, fputcsv() only encloses the field under the following conditions

    /* 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(' ')
    )
    

    There is no "always enclose" option.

提交回复
热议问题