file_put_contents overwrites data

六眼飞鱼酱① 提交于 2019-12-02 11:25:11

If you want to append new data into the file

you should use this flag

// this will append the content to the end of the file, 
// and prevent anyone else writing to the file at the same time
file_put_contents($file2, $content2, FILE_APPEND | LOCK_EX); 

Put below code after foreach(){ //your code for getting data and put into single variable }. Remove the same from inside foreach and remove $content2 = ""; too.

$file2 = 'trunk_test.conf';
error_log("======FILE path ====$file2======");
file_put_contents($file2, $content2, LOCK_EX);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!