PHP implements the replacement of multiple strings into the same code

WBOY
Release: 2016-07-25 08:58:39
Original
965 people have browsed it
  1. $name = 'Today 3? , very/ cold';
  2. $name = strtolower($name);
  3. //$name = preg_replace('/[^a-z0-9s ]/','',$name);
  4. $name = preg_replace('/[.s+?,/"]/','_',$name); //change spaces
  5. echo $name;
  6. ?> ;
Copy code

where:

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

.s+?,/" is a regular expression, indicating search. The empty symbol ? / " these five characters Others can be added by yourself. If you don’t understand something, you can refer to the content about regular expressions.



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