php多个字符串替换成同一个的解决方法_php技巧

WBOY
Release: 2016-05-17 09:00:34
Original
1085 people have browsed it
复制代码 代码如下:

$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+\?,\/"为正则表达式,表示查找.   空符号    ?    /     "        这五个字符
其他可自行添加,添加的时候要查找正则手册
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