正则过滤全角空格解决方案

WBOY
Release: 2016-06-13 12:57:21
Original
1448 people have browsed it

正则过滤全角空格
请问哪位有试过用正则过滤掉空格,要包括全角的。


------解决方案--------------------
转换成UTF-8,加u修正符
$s='ad sf中 ds';
echo preg_replace('/[  ]+/u','',$s);
------解决方案--------------------
\s 匹配任何空白字符,包括空格、制表符、换页符等等。等价于 [ \f\n\r\t\v]。
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template