假设 $body 等于:
我得到的结果是:
something
that
does
not
interest
me
<!-- start -->
some
html
code
<!-- end -->
something
that
does
not
interest
me
如果我使用
$body=preg_replace("(.*)<!-- start -->(.*)<!-- end -->(.*)","$2",$body);
我得到的结果是:
我该如何纠正?警告:preg_replace() [function.preg-replace]:未知修饰符'<'
strpos
获取 start 的位置和 end 的位置可能更容易,然后使用substr
只获取这些位置之间的部分。 - Gumbo