将一个txt文件内容附加到另一个退出的txt文件 [英] Appending one txt file content to another exiting txt file

查看:64
本文介绍了将一个txt文件内容附加到另一个退出的txt文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 names.txt 文件的内容附加到文件末尾的另一个名为 surname.txt 的文件中,而不会丢失以前的 surname.txt .

I am trying to append the names.txt file content to the another file called as surname.txt at the end of the file , without losing previous information of surname.txt .

实现此操作的可能方法是什么?要执行此操作,我正在使用php

What is possible way to achieve this operation ? To execute this operation , i am using php

以下解决方案工作完美!但是数据没有插入到新行中.

Following solution working perfect ! but data is not inserting to new line.

推荐答案

像下面一样,使用 FILE_APPEND 标志:

Like below, using FILE_APPEND flag:

file_put_contents('/path/to/surname.txt', file_get_contents('/path/to/names.txt'), FILE_APPEND | LOCK_EX);

这篇关于将一个txt文件内容附加到另一个退出的txt文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆