问题
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