Home  >  Article  >  Backend Development  >  Solution to replace multiple strings with the same one in php_PHP tutorial

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

WBOY
WBOYOriginal
2016-07-21 15:05:33996browse

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+?,/"]/'. ..
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