php多个字符串替换成同一个的解决方法_PHP
- WBOYOriginal
- 2016-06-01 12:06:00882browse
复制代码 代码如下:
$name = 'Today 3? , very/ cold';
$name = strtolower($name);
//$name = preg_replace('/[^a-z0-9\s]/','',$name);
$name = preg_replace('/[\.\s+\?,\/"]/','_',$name); //change spaces
echo $name;
?>
其中
复制代码 代码如下:
$name = preg_replace('/[\.\s+\?,\/"]/','_',$name); //change spaces
\.\s+\?,\/"为正则表达式,表示查找. 空符号 ? / " 这五个字符
其他可自行添加,添加的时候要查找正则手册
Statement: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