Possible Duplicate:
writing to a text file in php
Say I wanted to add the string $ip to the text file ip.txt in the same directory. I am currently using file_get_contents
to read from the text file.
You could use file_put_contents
<?php $ip = "foo"; file_put_contents("ip.txt", $ip, FILE_APPEND); ?>
FILE_APPEND
will append the text. Absence of this flag will cause file-overwriting.
file_put_contents()
with FILE_APPEND
flag appends text to given file:
file_put_contents('filename.txt', $stringToAppend, FILE_APPEND);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With