我认为你正在寻找:
html_entity_decode('باخ', ENT_QUOTES, 'UTF-8');
当你从ب到ب,这就是所谓的解码。做相反的事情叫做编码。
至于只替换؛到۹也许尝试这样的事情。
<?php
// Random set of entities, two are outside the 1563 - 1785 range.
$entities = '؛؜<لñ۸۹';
// Matches entities from 1500 to 1799, not perfect, I know.
preg_match_all('/[5-7][0-9]{2};/', $entities, $matches);
$entityRegex = array(); // Will hold the entity code regular expression.
$decodedCharacters = array(); // Will hold the decoded characters.
foreach ($matches[0] as $entity)
{
// Convert the entity to human-readable character.
$unicodeCharacter = html_entity_decode($entity, ENT_QUOTES, 'UTF-8');
array_push($entityRegex, "/$entity/");
array_push($decodedCharacters, $unicodeCharacter);
}
// Replace all of the matched entities with the human-readable character.
$replaced = preg_replace($entityRegex, $decodedCharacters, $entities);
?>
尽我所能解决这个问题。希望这会有所帮助。现在是我现在的5点,所以我要睡觉了! :)
是否有一个原因,你只会将一些HTML字符引用转换为字符?它会更容易,它会节省字节,将它们全部转换。 – 2013-04-05 10:40:22
@ JukkaK.Korpela如果我将它们全部转换,然后'<'和'>'也将转换为'<' and '>',这是我不想要的。 – Munib 2013-04-05 10:55:10