我想你正在寻找:
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:00,所以我要睡觉了!:)