Monday, 19 August 2013

PHP Write string to new line for the first time and not at the end of file

PHP Write string to new line for the first time and not at the end of file

Using Codeigniter function write_file(), I can write to an existing file
like this:
write_file("path_to_file", "String four"."\n", "a+");
Assume I already have a file like this:
String one
String two
String three
With write_file("path_to_file", "String four"."\n", "a+") , I have the
ouput below when writing to file for the first time:
String one
String two
String three String four
Any idea about how I can write String four to new line for the first time?
Like shown below:
String one
String two
String three
String four
Thanks.

No comments:

Post a Comment