php man page for fputcsv

Query: fputcsv

OS: php

Section: 3

Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar

FPUTCSV(3)								 1								FPUTCSV(3)

fputcsv - Format line as CSV and write to file pointer

SYNOPSIS
int fputcsv (resource $handle, array $fields, [string $delimiter = ","], [string $enclosure = '"'], [string $escape_char = "
DESCRIPTION
fputcsv(3) formats a line (passed as a $fields array) as CSV and write it (terminated by a newline) to the specified file $handle.
PARAMETERS
o $handle -The file pointer must be valid, and must point to a file successfully opened by fopen(3) or fsockopen(3) (and not yet closed by fclose(3)). o $fields - An array of values. o $delimiter - The optional $delimiter parameter sets the field delimiter (one character only). o $enclosure - The optional $enclosure parameter sets the field enclosure (one character only). o $escape_char - The optional $escape_char parameter sets the escape character (one character only).
RETURN VALUES
Returns the length of the written string or FALSE on failure.
CHANGELOG
+--------+---------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------+ | 5.5.4 | | | | | | | The $escape_char parameter was added | | | | +--------+---------------------------------------+
EXAMPLES
Example #1 fputcsv(3) example <?php $list = array ( array('aaa', 'bbb', 'ccc', 'dddd'), array('123', '456', '789'), array('"aaa"', '"bbb"') ); $fp = fopen('file.csv', 'w'); foreach ($list as $fields) { fputcsv($fp, $fields); } fclose($fp); ?> The above example will write the following to file.csv: aaa,bbb,ccc,dddd 123,456,789 """aaa""","""bbb"""
NOTES
Note If PHP is not properly recognizing the line endings when reading files either on or created by a Macintosh computer, enabling the auto_detect_line_endings run-time configuration option may help resolve the problem.
SEE ALSO
fgetcsv(3). PHP Documentation Group FPUTCSV(3)
Related Man Pages
getopt(3) - php
preg_quote(3) - php
px_create_fp(3) - php
class::csv(3pm) - debian
splfileobject.fputcsv(3) - php
Similar Topics in the Unix Linux Community
Remove Carriage returns between strings in a field
how to parse this string
Replacing the last character for each line in a file
Change specific occurence with sed
Change the delimiter from Comma to Pipeline