How to intercept a php string

Source: Internet
Author: User
How to intercept a php string? suppose there is a string $ addr = 'lanzhou telecom of Gansu province '. I want to retrieve the province and city information $ p = 'gansu province' $ c = 'lanzhou city '. how can I perform this operation? retrieve? Note: how can I intercept a $ p & nbsp ;=& nbsp; strstr ($ addr, & nbsp; 'save', true php string?
Assume there is a string
$ Addr = 'gansu Lanzhou telecom'
I want to retrieve the province and city information.
$ P = 'gansu province'
$ C = 'lanzhou'
How can I retrieve it?

Note: I am using $ p = strstr ($ addr, 'offset', true); the system prompts no third parameter.
Is there any other way to obtain
------ Solution --------------------
$ Addr = 'lanzhou Telecom, Gansu province ';
Preg_match_all ('/. +? (? : Province
------ Solution --------------------
City)/', $ addr, $ r );
List ($ p, $ c) = $ r [0];
Echo $ p;
Echo $ c;

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.