Home  >  Article  >  Backend Development  >  正则匹配求帮帮

正则匹配求帮帮

WBOY
WBOYOriginal
2016-06-13 13:24:59697browse

正则匹配求大虾帮帮
about.php?id=222 用正则怎么替换成 about_222.html 先谢谢了。

------解决方案--------------------
随便写了个,凑合吧.

PHP code

$str='about.php?id=222';
//about_222.html
$str=preg_replace('/([a-z\d\_]+)\..*id=([\d]+)$/',"$1_$2.html",$str);
echo $str; <div class="clear">
                 
              
              
        
            </div>
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
Previous article: php + nginx 装配 Next article: php exception错误处理