How to write in CSV file using PHP script? Actually I was also searching for that too. It is kind of easy task with PHP.
fputs(handler, content) - this function works efficiently for me. First you need to open the file in which you need to write content using fopen($CSVFileName, ‘w’).
$CSVFileName = “test.csv”;
$fp = fopen($CSVFileName, ‘w’);
//Multiple iterations to append the data using function fputs()
foreach ($csv_post as $temp)
{
$line = “”;
$line .= “Content 1″ . $comma . “$temp” . $comma . “Content 2″ . $comma . “16/10/2012″.$comma;
$line .= “\n”;
fputs($fp, $line);
}
For more content and complete code refere this: Write CSV file using PHP