php截取某二个特殊字符串间的某段字符串

WBOY
Release: 2016-06-23 13:47:01
Original
1029 people have browsed it

在php开发的过程中,有时候会用到截取某二个特殊字符串间的某个字符串,并对这个字符串做特殊的处理,那么对截取出来的字符串做什么特殊处理我们暂时不管,我们今天先讲php截取某二个特殊字符串间的某个字符串的方法,下面我们以截取[start]到[/end]之间的字符串,其中的代码如下:


<?phpheader ('content-type:text/html;charset=utf-8');$a=" 互联网出版许可证编号[start]华强北在线[/end]华强北商城,[start] ~~2014年,互联网出版许可证编号[/end] ,咦哟哟哟哟哟哟哟哟";//每一次查到start -end;$start1=strpos($a,'[start]',0);$end1=strpos($a,'[/end]',0);echo('<1>'.substr($a,$start1+7,$end1-$start1-7));//每二次查到start -end;$start2=strpos($a,'[start]',$start1+7);$end2=strpos($a,'[/end]',$end1-$start1-7);echo('<br>'.substr($a,$start2+7,$end2-$start2));?>
Copy after login


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template