且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在php中添加行定界符(\ n)

更新时间:2023-02-20 08:46:38

使用您当前的代码,最简单的方法就是将其附加到编写部分中.

With your current code, the simplest is to just append it in the write part...

fwrite($df, implode('|', $row).PHP_EOL);

使用PHP_EOL来实现平***立性.

uses PHP_EOL for platform independance.

或者您可以使用 fputcsv() ...

Or you could use fputcsv()...

fputcsv($df, $row, "|");

请注意,如果您确实需要使用它,则"\ n"将在输出中起作用.

Just to note that if you definitely need to use it, "\n" will work the same in the output.