Php intercepts the specified string solution

Source: Internet
Author: User
Php intercepts the specified string $ a = "s =/Toupiao/yulan/pid = 117 & amp; title = 2 & amp; selectform = 1" with such a string, I want to get the pid value, because the pid value is not long, sometimes the pid = 1, pid = 12, pid = 123 .... php intercepts a specified string
$ A = "s =/Toupiao/yulan/pid = 117 & title = 2 & selectform = 1" has such a string. I want to get the pid value in it, because the pid value is not long, sometimes the pid = 1, pid = 12, pid = 123 ......, then how can I extract the pid value? Php truncate string
------ Solution --------------------
$ A = "s =/Toupiao/yulan/pid = 117 & title = 2 & selectform = 1 ";
Preg_match ('/\ bpid = (\ d +)/', $ a, $ r );
Echo $ r [1];
117

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.