Home > Backend Development > PHP Tutorial > php 截取指定的字符串解决方案

php 截取指定的字符串解决方案

WBOY
Release: 2016-06-13 12:52:47
Original
899 people have browsed it

php 截取指定的字符串
$a="s=/Toupiao/yulan/pid=117&title=2&selectform=1"有这样一个字符串,我想获取当中pid的值,因为pid值是不定长的,有时会pid=1,pid=12,pid=123......,那我要如何才可以截取pid的值了?

php 截取 字符串
------解决方案--------------------
$a = "s=/Toupiao/yulan/pid=117&title=2&selectform=1";<br />
preg_match('/\bpid=(\d+)/', $a, $r);<br />
echo $r[1];
Copy after login
117
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