/** * @param $matches String * @return String */ static function decodeCharReferencesCallback($matches) { if ($matches[1] != '') { return SGString::decodeEntity($matches[1]); } elseif ($matches[2] != '') { return SGString::decodeChar(intval($matches[2])); } elseif ($matches[3] != '') { return SGString::decodeChar(hexdec($matches[3])); } elseif ($matches[4] != '') { return SGString::decodeChar(hexdec($matches[4])); } # Last case should be an ampersand by itself return $matches[0]; }