appending file with new line first
| From: | Guru Geek | Date: | Sun, 09 Feb 2003 22:12:41 +0000 |
| Subject: | appending file with new line first | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-134984@lists.php.net to get a copy of this message | ||
Hello,
Yep, me again, with yet another php question.
Maybe I'm too tired to see the easy solution...
I open a file and write to it:
$handle = fopen ($temp_file, 'a');
fwrite($handle, $original_info);
fclose ($handle);
Later I want to add to the above file:
$handle = fopen ($temp_file, 'a');
fwrite($handle, $new_info);
fclose ($handle);
Here's what the file now looks like:
original info
original info
original info
original info
new infonew info
I'm trying to achieve:
original info
original info
original info
original info
new info
new info
It writes the very first piece of new info on a new line. That is
good. The second piece of new info gets written right at the exact end
of the file. I've tried fwrite($handle, $new_info\n) but that creates
an error. So does fwrite($handle, $new_info\r);
How can I get the new info to go on its own line in the file?
Thanks,
Roger