The fputcsv() function formats a line as CSV and writes it to an open file.This function returns the length of the written string, or FALSE on failure.
int fputcsv ( resource $handle , array $fields [, string $delimiter = "," [, string $enclosure = '"' [, string $escape_char = "\\" ]]] )
fputcsv() formats a line (passed as a fields array) as CSV and write it (terminated by a newline) to the specified file handle.
The above example will write the following to file.csv:
aaa,bbb,ccc,dddd 123,456,789 """aaa""","""bbb"""
Parameter | Description |
---|---|
file | Required. Specifies the open file to write to |
fields | Required. Specifies which array to get the data from |
separator | Optional. A character that specifies the field separator. Default is comma ( , ) |
enclosure | Optional. A character that specifies the field enclosure character. Default is " |