<?php
$str= <<<HTML
<div class="spoiler"><span class="trigger"><img src="/images/tree/plus.gif" /><a href="#">Filejungle</a></span>
<div style="display: none">Content
</div>
</div><br/>
<br/>
HTML;
$str = preg_replace("#<span class=\"trigger\"\>\<img src=\"/images/tree/plus.gif\" /><a href=\"#\">(.*)\</a\>\</span\>#s", "", $str);
echo $str;
?>
警告:preg_replace()[function.preg-replace]:未知修饰符....
我如何纠正?
答案 0 :(得分:1)
您的分隔符为#
,但您也在<a href
中使用了分隔符。逃避它。
$str = preg_replace("#<span class=\"trigger\"\>\<img src=\"/images/tree/plus.gif\" /><a href=\"\#\">(.*)\</a\>\</span\>#s", "", $str);