php换行符

2019-04-17 22:38:54

使用str_replace 来替换换行  

$str = str_replace(array("\r\n", "\r", "\n"), "", $str);   


2、使用正则替换  

$str = preg_replace('//s*/', '', $str);  


3、使用php定义好的变量 (建议使用)  

$str = str_replace(PHP_EOL, '', $str);   


php字符串加回车注意事项

php添加回车 注意事项 "\n\t" ,注意一定要用双引号,单引号直接输出这个字符。



$data = preg_replace_callback('/(([\n\r])\S+?(jpg))/', function ($matches) {

   /*为了设置图片有效期为当天*/

 //  error_log(json_encode($matches));
   $http = "http://demo.sadfasf.com/a/";
   $href = $http.$matches[0];
   $href = str_replace(array("\r\n", "\r", "\n"), "", $href);
   $href =  DTools::getQiniuAntiLeechAccessUrlBasedOnTimestamp($href);


   return "\r\n" .$href;
}, $data);



  • 2020-05-06 14:43:53

    bootstrap @media尺寸

    超大屏,1100分辨率,880分辨率,720分辨率,440分辨率以下

  • 2020-05-06 22:23:15

    使用querySelector添加移除style和class

    document.querySelector(selector).style.styleName = 样式 使用这个方法可以对dom节点添加和移除style样式,其中的styleName可以为css样式的任何值,如:display、color

  • 2020-05-07 13:05:28

    JavaScript中批量设置Css样式

    setAttribute() 方法添加指定的属性,并为其赋指定的值。 如果这个指定的属性已存在,则仅设置/更改值

  • 2020-05-07 13:07:21

    scrollBox 跑马灯滚动js

    ​这个插件可以很好的实现跑马灯,以及轮播图等效果,scrollBox js