- preg_replace_callback: documentation ( source)
- htmlspecialchars_decode: documentation ( source)
- htmlentities: documentation ( source)
- strip_tags: documentation ( source)
<?php
{
$html = preg_replace_callback(
"# <(?![/a-z]) | (?<=\s)>(?![a-z]) #xi",
function ($matches) {
return htmlentities($matches[0]);
},
$html
);
$html = strip_tags($html);
return htmlspecialchars_decode($html);
}