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 codestr_replace("\n", '', str_replace("\r\n", "\n", $a));
or
str_replace(PHP_EOL, "\n", $a )想了解更多编程学习,敬请关注php培训栏目!