正则嘛,删除字母数字下划线以外的字符是很常见的需求,随手翻个代码总结如下:
$str = preg_replace("/[^a-zA-Z0-9_]/", '', $str);
相关参考资料
PHP: How to strip unwanted ch[……]
正则嘛,删除字母数字下划线以外的字符是很常见的需求,随手翻个代码总结如下:
$str = preg_replace("/[^a-zA-Z0-9_]/", '', $str);
相关参考资料
PHP: How to strip unwanted ch[……]