PHP第一次将字符串写入新行,而不是在文件末尾 [英] PHP Write string to new line for the first time and not at the end of file
本文介绍了PHP第一次将字符串写入新行,而不是在文件末尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用Codeigniter函数 write_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
使用 write_file( path_to_file,字符串四。 \n, a +)
,我在写文件时有以下输出第一次:
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
谢谢。
推荐答案
对此write_file()函数了解不多,但是按照您所说的,这应该可以工作:
Not knowing much about this write_file() function, but given what you said, this should work :
write_file("path_to_file", "\n"."String four"."\n", "a+")
这篇关于PHP第一次将字符串写入新行,而不是在文件末尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文