Home > Backend Development > PHP Tutorial > php 正则轮换

php 正则轮换

WBOY
Release: 2016-06-13 12:56:47
Original
998 people have browsed it

php 正则替换
某个字符串,希望把非字母和数字的之外的都替换掉。
比如$tname="d#$(,)123"  过滤完成以后 应该是:$tname="d123"


------解决方案--------------------
echo preg_replace('/[^a-z0-9]+/i','',$tname);
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