Solution to replace multiple strings with the same one in php_PHP tutorial

WBOY
Release: 2016-07-21 15:05:33
Original
1040 people have browsed it

Copy code The code is as follows:

$name = 'Today 3?, very/ cold';
$name = strtolower($name);
//$name = preg_replace('/[^a-z0-9s]/','',$name);
$name = preg_replace(' /[.s+?,/"]/','_',$name); //change spaces
echo $name;
?>

where
Copy code The code is as follows:

$name = preg_replace('/[.s+?,/"]/','_' ,$name); //change spaces

.s+?,/" is a regular expression, indicating search. Empty symbol ? / / " These five characters
and others can be added by yourself. When searching for the regular manual

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327694.htmlTechArticleCopy the code as follows: ?php $name = 'Today 3? , very/ cold'; $name = strtolower ($name); //$name = preg_replace('/[^a-z0-9s]/','',$name); $name = preg_replace('/[.s+?,/"]/'. ..
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