Questions tagged «linefeed»




4
在PHP中编写新行到文件(换行)
我的代码: $i = 0; $file = fopen('ids.txt', 'w'); foreach ($gemList as $gem) { fwrite($file, $gem->getAttribute('id') . '\n'); $gemIDs[$i] = $gem->getAttribute('id'); $i++; } fclose($file); 由于某种原因,它\n以字符串形式编写,因此文件如下所示: 40119\n40122\n40120\n42155\n36925\n45881\n42145\n45880 根据Google的指示,它告诉我使用\r\n,但\r它是回车符,这似乎不是我想要执行的操作。我只希望文件看起来像这样: 40119 40122 40120 42155 36925 45881 42145 45880 谢谢。
109 php  newline  fopen  fwrite  linefeed 

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.