Fixing quote escaping in backreference replacements
<?php
$html = "<code><b> It's bold </b></code>";
print preg_replace('@<code>(.*?)</code>@e',"preg_html_entity_decode('$1')", $html);
print "\n";
$html = '<code><i> "This" is italic. </i></code>';
print preg_replace('@<code>(.*?)</code>@e',"preg_html_entity_decode('$1')", $html);
print "\n";
function preg_html_entity_decode($s) {
$s = str_replace('\\"','"', $s);
return html_entity_decode($s);
}
?>
Related examples in the same category