fputcsv(3) php man page | unix.com

Man Page: fputcsv

Operating Environment: php

Section: 3

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
fgetcsv(3) - php
fwrite(3) - php
px_create_fp(3) - php
class::csv(3pm) - debian
Similar Topics in the Unix Linux Community
line feeds in csv
how to get filename from directory
subtitute specific column in line
Replacing the last character for each line in a file
change a field in a file