Output text file with line breaks in PHP

前端 未结 9 1081
一个人的身影
一个人的身影 2020-11-28 14:11

I\'m trying to open a text file and output its contents with the code below. The text file includes line breaks but when I echo the file its unformatted. How do I fix this?<

9条回答
  •  南笙
    南笙 (楼主)
    2020-11-28 14:49

    Are you outputting to HTML or plain text? If HTML try adding a
    at the end of each line. e.g.

    while (!feof($handle)) {
      $buffer = fgets($handle, 4096); // Read a line.
      echo "$buffer
    "; }

提交回复
热议问题