Blogger Information
Blog 250
fans 3
comment 0
visits 321826
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
正则表达式函数:preg_replace()
梁凯达的博客
Original
1481 people have browsed it

//str_replace()
 //函数用于匹配字符串并用字符串进行替换
 //参数:str_replace([要替换的内容],[被替换的内容],[替换的字符串])
 //返回值是替换后的字符串
 $str = '呵呵呵哈哈哈';
 echo $str;
 echo '<hr />';
 $str1 = str_replace('呵呵','嗯哼?',$str);
 echo $str1;
 
 //preg_replace()
 //函数用于用正则表达式匹配字符串,并提供替换值
 //函数参数:preg_replace(([正则表达式],[要替换的内容],[被查找的字符串]);
 $arr = array(
  '见证奇迹的asd时刻',
  '创建一个索引数组',
  '这是用字符串匹配的函数'
 );
 $preg = '/\w/';
 $result = preg_replace($preg,'ddd',$arr);
 var_dump($result);

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post