Home > php教程 > php手册 > php多个字符串替换成同一个的解决方法

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

WBOY
Release: 2016-06-06 20:30:52
Original
1094 people have browsed it

本篇文章是对php多个字符串替换成同一个的方法进行了详细的分析介绍,需要的朋友参考下

复制代码 代码如下:


$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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template