保留换行符txt php [英] Preserve linebreak txt php

查看:110
本文介绍了保留换行符txt php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从服务器读取.txt文件并保留其换行符? 请注意,换行符不是这样的/n之类的东西,它们更像是

How can I read a .txt file from my server, and preserve it's linebreaks? Note that the linebreaks aren't like this /n or something, they are more like

这个.您知道的只是纯文本的新行.

this. You know, just a new line in plain text.

我想从服务器上回显.txt文件,该文件使用PHP或其他方式,同时保留换行符.

I would like to echo the .txt file from my server, this is in PHP or something, while preserving the linebreaks.

先谢谢了! :)

推荐答案

用于输出?只需使用nl2br

$file = file_get_contents( 'file.txt' );
echo nl2br( $file );

还可以与fopen一起使用.

这篇关于保留换行符txt php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆