I have content that is first htmlentities and then stripslashes followed by nl2br.
This means a watermark at the end ends up as:
<li><p><!-- watermark --></p></li>
Not very useful. I have the code below to try and strip the html comments and stop it displaying but its not very good at it!
$methodfinal = str_replace('<li><p><!--', '<!--', $method);
$methodfinal2 = str_replace('--></p></li>', '-->', $methodfinal);
echo $methodfinal2;
anyone got any ideas?
EDIT:
following Zed’s and your comments I’ve done some testing and this is what you should use:
Here is a breakdown of the RE:
this is obvious
because you have a few spaces and a newline between the
<li>and the comment, but we want the least number of newlines so we use the non greedy *? (it sould work with * as well)need to escape the ;
again we use *? so we would match only this line (other wise if you had the same line again it wold match from the first one to the last one
same as above
so php would treat newlines as whitespace (i am not sure about this but it seems to be working)