SSK
SSK

Reputation: 285

Appending one txt file content to another exiting txt file

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 .

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.

Upvotes: 2

Views: 2621

Answers (1)

xdazz
xdazz

Reputation: 160973

Like below, using FILE_APPEND flag:

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

Upvotes: 4

Related Questions