-1
<?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;
?>

Warning: preg_replace() [function.preg-replace]: Unknown modifier....

How have I to correct?

Thoman
  • 742
  • 2
  • 9
  • 20

1 Answers1

1

Your delimiter is # but you're using it in your <a href as well. Escape it.

$str = preg_replace("#<span class=\"trigger\"\>\<img src=\"/images/tree/plus.gif\" /><a href=\"\#\">(.*)\</a\>\</span\>#s", "", $str);
Tom van der Woerdt
  • 29,532
  • 7
  • 72
  • 105