PHP | SplFileObject fputcsv() Function Last Updated : 21 Dec, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The SplFileObject fputcsv() function is an inbuilt function of Standard PHP Library (SPL) in PHP which is used write a field array as a CSV line. Syntax: string SplFileObject::fputcsv() Parameters: This function accept four parameters one is mandatory and three are optional. $fields: Specifies the an array of values. $delimiter: An optional parameter which specify sets the field delimiter. $enclosure: An optional parameter which specify field enclosure. $escape: An optional parameter used for escape character. Return values: This function returns length of the written string or FALSE otherwise. Below Program illustrate the SplFileObject fputcsv() function in PHP. Program : php <?php // Create an Array $gfg = array ( array('gfg', 'geeks', 'gced', 'Article'), array('Hello', 'Sudo', 'Placement'), array('"Contribute"', '"Interview"'), array('"System"', '"IDE"') ); // Creating Spl Object $file = new SplFileObject('gfg.csv', 'w'); foreach ($gfg as $arr) { $file->fputcsv($arr); } echo "Successfully write data in gfg.csv"; ?> Output: Successfully write data in gfg.csv When Run the Above program it will create a gfg.csv file if not exist and writes the content of array in file as shown in below image. Reference: http://php.net/manual/en/splfileobject.fputcsv.php Comment More infoAdvertise with us Next Article PHP | SplFileObject fstat() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-SplFileInfo Similar Reads PHP | SplFileObject fgetc() Function The SplFileObject::fgetc() function is an inbuilt function of Standard PHP Library (SPL) in PHP which is used to get character from file. Syntax: string SplFileObject::fgetc( void ) Parameters: This function does not accept any parameter. Return values: Returns single character read from the file or 1 min read PHP | SplFileObject fgets() Function The SplFileObject::fgets() function is an inbuilt function of the Standard PHP Library (SPL) in PHP which is used to get a line from the file. Syntax: string SplFileObject::fgets( void ) Parameters: This function does not accept any parameter. Return values: This function returns a string contain 1 min read PHP SplFileObject fflush() Function The SplFileObject::fflush() function is an inbuilt function in the Standard PHP Library (SPL) in PHP that is used to flush the output buffer of the file. Syntax: public SplFileObject::fflush():boolParameter: This function does not accept any parameters. Return Value: The SplFileObject::fflush() func 2 min read PHP | SplFileObject fgetss() Function The SplFileObject::fgetss() function is an inbuilt function of Standard PHP Library (SPL) in PHP which is used to get line from file and strip HTML tags.Syntax:  string SplFileObject::fgetss( $tags) Parameters: This function accept only one parameter $tags an optional parameter to specify tags whic 1 min read PHP | SplFileObject fstat() Function The SplFileObject::fstat() function is an inbuilt function of Standard PHP Library (SPL) in PHP which is used to give the information of the file. Syntax: array SplFileObject::fstat( void ) Parameters: This function does not accept any parameter. Return values: This function returns an array which c 1 min read PHP SplFileObject fseek() Function The SplFileObject::fseek() function is an inbuilt function of Standard PHP Library (SPL) in PHP that allows you to move the file pointer to a specified position within a file opened using SplFileObject. The file pointer is the position where the next read or write operation will occur. This function 2 min read Like