Home > Backend Development > PHP Tutorial > 正则匹配求帮帮

正则匹配求帮帮

WBOY
Release: 2016-06-13 10:30:58
Original
878 people have browsed it

正则匹配求大虾帮帮
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>
Copy after login
Related labels:
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