Home  >  Article  >  Backend Development  >  求一正则 数字.html

求一正则 数字.html

WBOY
WBOYOriginal
2016-06-20 12:38:27797browse

tp碰到,传来一url
http://www.xxx.xx.com/weiphp/user/passid/567.html大致这样的地址
在user方法里死活得不到 567这个值,get post 等等都试了,不好用了,于是乎,求个正则,把得到的地址放到字符串里,然后取567这个值

谢谢啦


回复讨论(解决方案)

不需要正则这么麻烦

$path = 'http://www.xxx.xx.com/weiphp/user/passid/567.html';$passid = basename($path,'.html');


这样就能取到passid了

preg_match('/(\d+)\.html$/', $path, $match);var_dump($match);

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