PHP intercepts a string between two special strings

Source: Internet
Author: User

In the process of PHP development, sometimes used to intercept a certain string of two special strings, and to do special processing of the string, then what special processing of the intercepted string, we do not care, we first talk about PHP interception of a string between a two special string method, Here's a string that intercepts [start] to [/end], where the code is as follows:


<?phpheader (' content-type:text/html;charset=utf-8 '); $a = "Internet Publishing license number [start] huaqiang North Online [/end] Huaqiang North Mall, [start] ~~2014 year, Internet Publishing license number [/end], hey yo yo yo yo yo, "//every time to find Start-end; $start 1=strpos ($a, ' [start] ', 0); $end 1=strpos ($a, ' [/end] ', 0); Echo (' <1> '. substr ($a, $start 1+7, $end 1-$start 1-7));//two-time check start-end; $start 2=strpos ($a, ' [start] ', $start 1+7); $end 2 =strpos ($a, ' [/end] ', $end 1-$start 1-7), Echo (' <br><2> '. substr ($a, $start 2+7, $end 2-$start 2));? >


PHP intercepts a string between two special strings

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.