bre*_*ett 5 php file-io newline file
不确定可能是什么问题.
我将数据从一个数组转储$theArray到theFile.txt一个单独的行中的每个数组项.
$file = fopen("theFile.txt", "w");
foreach ($theArray as $arrayItem){
fwrite($file, $arrayItem . '\n');
}
fclose($file);
Run Code Online (Sandbox Code Playgroud)
问题是当我打开时theFile.txt,我看到\n字面输出.此外,如果我尝试以编程方式逐行读取文件(只是在有行的情况下),它会将它们显示为1行,这意味着\n它们没有达到预期的效果.