How to append the text to text if file already exists in PHP

1 Answer

0 votes
$file = file_put_contents('data.txt', "text to write to file - 1" . PHP_EOL, FILE_APPEND | LOCK_EX);
$file = file_put_contents('data.txt', "text to write to file - 2" . PHP_EOL, FILE_APPEND | LOCK_EX);
$file = file_put_contents('data.txt', "text to write to file - 3" . PHP_EOL, FILE_APPEND | LOCK_EX);



/*
run:

text to write to file - 1
text to write to file - 2
text to write to file - 3

*/

 



answered Oct 17, 2020 by avibootz

Related questions

1 answer 289 views
2 answers 328 views
1 answer 289 views
1 answer 282 views
3 answers 428 views
1 answer 388 views
1 answer 302 views
302 views asked Dec 16, 2015 by avibootz
...