Mega Code Archive

 
Categories / Php / Strings
 

Quote escaping in backreference replacements

<?php $html = "<code>&lt;b&gt; It's bold &lt;/b&gt;</code>"; print preg_replace('@<code>(.*?)</code>@e',"html_entity_decode('$1')", $html); print "\n"; $html = '<code>&lt;i&gt; "This" is italic. &lt;/i&gt;</code>'; print preg_replace('@<code>(.*?)</code>@e',"html_entity_decode('$1')", $html); print "\n"; ?>