PHP Generating Replacement Strings With Callback Function – String Function

<?php
$html = 'The &lt;b&gt; tag makes text bold: <code>&lt;b&gt;bold&lt;/b&gt;</code>';
print preg_replace_callback('@<code>(.*?)</code>@','decode', $html);function decode($matches) {
    return html_entity_decode($matches[1]);
}
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.