Generating replacement strings with a callback function
<?php
$html = 'The <b> tag makes text bold: <code><b>bold</b></code>';
print preg_replace_callback('@<code>(.*?)</code>@','decode', $html);
function decode($matches) {
return html_entity_decode($matches[1]);
}
?>
Related examples in the same category