Reputation: 1037
I have a file that has the following structure :
I'm trying to insert a new line at the end using this function :
ini_set('auto_detect_line_endings',true);//At the beginning of the php file
$handle = fopen("File.csv", "r+");
$line = array(
[0] => Trussville
[1] => L01
[2] => 8765
[3] => this is , a sample (xx)
);
fputcsv($handle, $line, ',', '"');
fclose($handle);
The result I get is as following :
Can help me please ? Thanks
Upvotes: 0
Views: 552
Reputation: 1057
before writing, position the file pointer to the end of the file, like so:
...
fseek($handle, 0, SEEK_END);
fputcsv($handle, $line, ',', '"');
Upvotes: 1