您好,欢迎来到爱go旅游网。
搜索
您的当前位置:首页php如何解决回车换行符的转换问题

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

来源:爱go旅游网

php解决回车换行符转换的方法:1、使用file函数,代码为【$list = file($intstr)】;2、使用replace函数,代码为【ereg_replace(" ", "", $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("/[
]+/", ',', $a);或$a = join(',', split("[
]+", $a));

方法4:

ereg_replace("
", "", $value);

最后一个知道的,PHP code

str_replace("
", '', str_replace("
", "
", $a));
or
str_replace(PHP_EOL, "
", $a )

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

Copyright © 2019- igat.cn 版权所有 赣ICP备2024042791号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务