splfileobject.fputcsv(3) php man page | unix.com

Man Page: splfileobject.fputcsv

Operating Environment: php

Section: 3

SPLFILEOBJECT.FPUTCSV(3)						 1						  SPLFILEOBJECT.FPUTCSV(3)

SplFileObject::fputcsv - Write a field array as a CSV line

SYNOPSIS
public int SplFileObject::fputcsv (array $fields, [string $delimiter = ","], [string $enclosure = '"'], [string $escape = "
DESCRIPTION
Writes the $fields array to the file as a CSV line.
PARAMETERS
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 - The optional $escape parameter sets the escape character (one character only).
RETURN VALUES
Returns the length of the written string or FALSE on failure. Returns FALSE, and does not write the CSV line to the file, if the $delimiter or $enclosure parameter is not a single character.
ERRORS
/EXCEPTIONS An E_WARNING level error is issued if the $delimiter or $enclosure parameter is not a single character.
CHANGELOG
+--------------+-------------------------------+ | Version | | | | | | | Description | | | | +--------------+-------------------------------+ |5.5.21, 5.6.5 | | | | | | | Added the $escape parameter. | | | | +--------------+-------------------------------+
EXAMPLES
Example #1 SplFileObject::fputcsv example <?php $list = array ( array('aaa', 'bbb', 'ccc', 'dddd'), array('123', '456', '789'), array('"aaa"', '"bbb"') ); $file = new SplFileObject('file.csv', 'w'); foreach ($list as $fields) { $file->fputcsv($fields); } ?> The above example will write the following to file.csv: aaa,bbb,ccc,dddd 123,456,789 """aaa""","""bbb"""
SEE ALSO
fputcsv(3), SplFileObject::fgetcsv. PHP Documentation Group SPLFILEOBJECT.FPUTCSV(3)
Related Man Pages
ses(7d) - sunos
fgetcsv(3) - php
splfileobject(3) - php
class::csv(3pm) - debian
splfileobject.fputcsv(3) - php
Similar Topics in the Unix Linux Community
subtitute specific column in line
Replacing the last character for each line in a file
Change specific occurence with sed
How to parse csv format?
String has * as the field delimiter and I need echo/awk to escape it, how?