In the process of PHP development, sometimes used to intercept a certain two special string between a string, and the string to do special processing, then the intercepted string do what special handling we temporarily regardless. Let's talk today about PHP's method of intercepting a string between two special strings, and here we take the string between [start] and [/end], where the code is like this:
<?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