I am trying to remove a part of a document on the fly using preg_replace()
.
/* target example:
<li id="footer-poweredbyico">
<img src="//bits.wikimedia.org/skins-1.18/common/images/poweredby_mediawiki_88x31.png" alt="Powered by MediaWiki" width="88" height="31" />
</li>
*/
$reg = preg_quote('<li id="footer-poweredbyico">.*?</li>');
preg_replace($reg,"",$str);
Ignore any errors in PHP, this question is about how to format the regular expression correctly to remove anything matching the target example opening and closing tags. The contents of the containing HTML tags will be different each time, hence .*?
(I think that's wrong).