将命名的HTML实体转换为数字HTML实体 [英] Converting named HTML entities to numeric HTML entities
本文介绍了将命名的HTML实体转换为数字HTML实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有PHP函数将命名的HTML实体转换为它们各自的数字HTML实体?
Is there a PHP function to convert named HTML entities into their respective numeric HTML entities?
例如:
$str = "Oggi è un bel giorno";
echo entities_to_unicode($str); // Oggi è un bel giorno
预先感谢,祝您有愉快的一天!
Thanks in advance, have a nice day!
推荐答案
echo preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").";"', html_entity_decode($str))
这篇关于将命名的HTML实体转换为数字HTML实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文