通过PHP将阿拉伯数字html实体转换为字符
I have some string with arabic encoded and ukrainian (cyrillyc) words, like this:
$string = "اِئْتِلافِيٌّ - коаліційний, гармонійний;";
and I want to get characters (arabic) instead all this "&#xxxx;"`s.
If I putting this string into html, I'm getting exactly what i want: "اِئْتِلافِيٌّ - коаліційний, гармонійний;"
But when I use html_entitis_decode, it does nothing. (mb because arabic encoding does not supports with this function, just basic ASCII). So, plz tell me what should I do to get same result as browser interpreter?
我有一些带有阿拉伯语编码和乌克兰语(cyrillyc)的字符串,如下所示: p> \ n
$ string =“اِئْتِل&#1575 ;فِيٌّ - коаліційний,гармонійний;“;
code> pre>
我希望得到字符(阿拉伯语)而不是所有这些“& #xxxx;”`s。 p>
如果我把这个字符串放到html中,我就得到了我想要的东西:
“ائتلافي - коаліційний,гармонійний;” p>
但是当我使用html_entitis_decode时,它什么也没做。 (mb,因为阿拉伯语编码不支持此功能,只支持基本ASCII)。
,请告诉我如何获得与浏览器解释器相同的结果? p>
div>
Your PHP version is probably older than 5.4.0, thus html_entity_decode
is not using UTF-8.
Encoding to use. If omitted, the default value for this argument is ISO-8859-1 in versions of PHP prior to 5.4.0, and UTF-8 from PHP 5.4.0 onwards.
http://php.net/manual/en/function.html-entity-decode.php
Try the following:
$decoded_string = html_entity_decode($string, ENT_COMPAT | ENT_HTML401, "UTF-8");