str_html_encode

Custom PHP Function


function str_html_encode($str) { $tags = array("i", "em", "b", "strong", "sup", "strike"); $pattern = '%(?:&lt;|&#60;|\\[)(\\/?(?:' . implode('|', $tags) . '))(?:&gt;|&#62;|\\])%'; $str = htmlentities($str); $str = preg_replace($pattern, '<$1>', $str); return $str; }