一起源码网

标题: php中如何替换换行符的实例代码解析 [打印本页]

作者: 云文章    时间: 2020-3-29 22:30
标题: php中如何替换换行符的实例代码解析
php中如何替换换行符的实例代码解析

//php 有三种方法来解决 
  
//1、使用str_replace 来替换换行 
$str = str_replace(array("
", "
", "
"), "", $str); 
  
//2、使用正则替换 
$str = preg_replace('//s*/', '', $str); 
  
//3、使用php定义好的变量 (建议使用) 
$str = str_replace(PHP_EOL, '', $str);
// 转为前台可显示的换行, nl2br 的方向函数参考php手册
$str = "a
b
e
f
c";

echo nl2br($str);


作者: 五行缺钱    时间: 2022-9-14 13:45
立体播放器源码




欢迎光临 一起源码网 (https://www.171739.xyz/) Powered by Discuz! X3.3