Home > PHP > Function > Filesystem > fputcsv()

fputcsv()

fputcsv - Format line as CSV and write to file pointer

Syntax

int fputcsv (resource $handle, array $fields, string $delimiter, string $enclosure)

Arguments

  • handle - The file pointer must be valid, and must point to a file successfully opened by fopen() or fsockopen() (and not yet closed by fclose()).
  • fields - An array of values.
  • delimiter - The optional delimiter parameter sets the field delimiter (one character only).
  • enclosure - The optional enclosure parameter sets the field enclosure (one character only).

Description

fputcsv() formats a line (passed as a fields array) as CSV and write it (terminated by a newline) to the specified file handle.

Version

PHP 5.1.0

Return value

Returns the length of the written string or FALSE on failure.