首页 > 后端开发 > php教程 > php str_replace 输入框回车替换br

php str_replace 输入框回车替换br

高洛峰
发布: 2016-11-29 11:54:36
原创
1708 人浏览过

在我们用textarea时会发现回车与空格是不可看到的,所以我们利用str_replace函数将php中的\\n替换成br就可以了,有需要的朋友可以参考,代码如下:

function htmtocode($content) { 

    $content = str_replace("n", "
", str_replace(" ", " ", $content)); 

    return $content; 

先替换掉空格,再替换回车,相当于如下代码:

function htmtocode($content) { 

    $content = str_replace(" ", " ", $content); 

    $content = str_replace("n", "
",$content);    

    return $content; 

    //开源代码phpfensi.com 

}


相关标签:
php
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
怎么学好php
来自于 1970-01-01 08:00:00
0
0
0
PHP扩展intl
来自于 1970-01-01 08:00:00
0
0
0
php数据获取?
来自于 1970-01-01 08:00:00
0
0
0
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板