4月62014
Php 去掉字符串中的空格回车
发布:2014-4-6 0:41 Sunday 分类:Php
阅读:4065次 评论:0条
写php的时候由于输出的字符串里面有回车和空格导致了程序的报错!所以搜索了一下这么去掉字符串里面的空格和回车!我用了2个函数 strip_tags 和preg_replace
strip_tags 用于把字符串里面的html代码都掉!生产纯属的字符串
preg_replace 是把字符串里面的空白和回车后去掉
代码如下:
$zfc = $ml // 这里是你的字符串
$hpz = strip_tags($zfc);$zpnl = preg_replace('#\s+#', ' ',trim($hpz));
本文固定链接: http://alzhai.com/post-335.html