Auth_Yadis_ParseHTML::replaceEntities PHP Method

replaceEntities() public method

Replace HTML entities (amp, lt, gt, and quot) as well as numeric entities (e.g. #x9f;) with their actual values and return the new string.
public replaceEntities ( string $str ) : string
$str string The string in which to look for entities
return string $new_str The new string entities decoded
    function replaceEntities($str)
    {
        foreach ($this->_entity_replacements as $old => $new) {
            $str = preg_replace(sprintf("/&%s;/", $old), $new, $str);
        }
        // Replace numeric entities because html_entity_decode doesn't
        // do it for us.
        $str = preg_replace_callback('/&#x([0-9a-f]+);/i', function ($matches) {
            return chr(hexdec($matches[1]));
        }, $str);
        $str = preg_replace_callback('/&#([0-9]+);/', function ($matches) {
            return chr($matches[1]);
        }, $str);
        return $str;
    }