I am using php code to write into my csv file , its able to write successfully but every time i run my code the older data is lost and csv file is left with data which only the current run contains.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.
Fputcsv() Is Writing To My File But Erasing The Previous Data
in PHP Coding Help
Posted
HI all,
I am using php code to write into my csv file , its able to write successfully but every time i run my code the older data is lost and csv file is left with data which only the current run contains.
I used this
<?
$list = array (
array('aaa', 'bbb', 'ccc', 'dddd'),
array('123', '456', '789'),
array('"aaa"', '"bbb"')
);
$fp = fopen('test.txt', 'w');
foreach ($list as $fields) {
fputcsv($fp, $fields);
}
fclose($fp);
?>
Any suggestions???
Many thanks .