Is there a PHP function to convert named HTML entities into their respective numeric HTML entities?
For example:
$str = \"Oggi è un bel&am
This solution is based on the code from php.net:
function entities_to_unicode($str) {
$str = html_entity_decode($str, ENT_QUOTES, 'UTF-8');
$str = preg_replace_callback("/([0-9]+;)/", function($m) { return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES"); }, $str);
return $str;
}
$str = 'Oggi è un bel giorno';
echo entities_to_unicode($str);