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