找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索本站精品资源

首页 教程频道 查看内容

php如何解决回车换行符的转换问题

作者:模板之家 2020-9-30 10:37 6824人关注

php解决回车换行符转换的方法:1、使用file函数,代码为【$list = file($intstr)】;2、使用replace函数,代码为【ereg_replace(\r\n, , $value);】。

php解决回车换行符转换的方法:1、使用file函数,代码为【$list = file($intstr)】;2、使用replace函数,代码为【ereg_replace("\r\n", "", $value);】。

php解决回车换行符转换的方法:

方法 1 :nl2br(PHP 4, PHP 5)

nl2br — Inserts HTML line breaks before all newlines in a string

方法2:可以采用file()函数,例子如下

function fmtfilenl($intstr)
{
 $list = file($intstr);
 foreach($list as $row) {
    $outstr=$outstr.$row.'
';
 }
 return $outstr;
}

方法3:

$a = preg_replace("/[\r\n]+/", ',', $a);或$a = join(',', split("[\r\n]+", $a));

方法4:

ereg_replace("\r\n", "", $value);

最后一个知道的,PHP code

str_replace("\n", '', str_replace("\r\n", "\n", $a));
or
str_replace(PHP_EOL, "\n", $a )

想了解更多编程学习,敬请关注php培训栏目!

以上就是php如何解决回车换行符的转换问题的详细内容,更多请关注模板之家(www.mb5.com.cn)其它相关文章!


路过

雷人

握手

鲜花

鸡蛋
来自: 网络收集

全部回复(0)