Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to write data into csv file?
03-09-2010, 06:59 PM
Post: #1
how to write data into csv file?
Hi all,

Does anyone know how to write data into csv file? I was using fwrite() to do this now but all its data will write into the 1st cell of the csv file only. Thanks in advance for anyone who offers help.
Find all posts by this user
Quote this message in a reply
03-09-2010, 07:08 PM
Post: #2
RE: how to write data into csv file?
use the fputcsv function:

PHP Code:
$fp = fopen ( 'my_csv_file.csv', 'w' );
fputcsv ( $fp, array ( 'field_value1', 'field_value2', 'field_value3' ), ",", '"' );
fclose ( $fp );

will output something like this in the my_csv_file.csv file:

Code:
"field_value1", "field_value2", "field_value3"
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:

Contact UsDeveloper SolutionReturn to TopReturn to ContentLite (Archive) ModeRSS Syndication