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:
立即学习“PHP免费学习笔记(深入)”;
$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如何解决回车换行符的转换问题的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号