preg_match_all()正则取数据,为什么少了最后一个数字?

WBOY
Release: 2016-06-23 14:25:03
Original
1427 people have browsed it

preg_match_all('/id=(.*)[0-9]/', 'http://www.baidu.com/go.htm?spm=a1z10.1.w5003-4193336463.1.aoWyoL&id= 35468681941&scene=baidu_session', $id);

我想要拿到网址中的id值。
上面那样只能拿到3546868194,少了个1。这是为什么呢?


回复讨论(解决方案)

写成这样可以了,谢谢各位。
preg_match_all('/id\=(\d+)/',

额,我只知道怎么改,不知道为什么.....如果你只想匹配数字只要  /id=[0-9]*/  就好啦,  
/id=(.*)[0-9]/这个太乱了,连模式单元都用上了..

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