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 189 views
2 answers 200 views
1 answer 196 views
1 answer 190 views
3 answers 299 views
1 answer 258 views
1 answer 193 views
193 views asked Dec 16, 2015 by avibootz
...