Append to next line in text file using php [duplicate]

戏子无情 提交于 2019-12-20 05:00:29

问题


I have a php script which passes a value to a .txt file, there is no problem and it works, the only thing is I would like to append the value to the next line instead of just append the value right after another value so instead of "valuevalue" I would like:

value

value

My script:

$filename4 = "EmailsFromSignUp.txt";
$content = file_get_contents($filename4);
$content .= $emailFPay;
file_put_contents($filename4, $content);

回答1:


Try

$content .= PHP_EOL . $emailFPay;



回答2:


$f = fopen("EmailsFromSignUp.txt", "a+");
fputs($f, "\n" . $emailFPay);
fclose($f);



回答3:


$filename4 = "EmailsFromSignUp.txt";
$content = file_get_contents($filename4);
$content .= "\r\n" . $emailFPay;
file_put_contents($filename4, $content);


来源:https://stackoverflow.com/questions/29780379/append-to-next-line-in-text-file-using-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!