Return to Snippet

Revision: 3548
at August 10, 2007 06:24 by nicolaspar


Initial Code
function unhtmlentities($cadena){
    // reemplazar entidades numericas
    $cadena = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $cadena);
    $cadena = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $cadena);
    // reemplazar entidades literales
    $trans_tbl = get_html_translation_table(HTML_ENTITIES);
    $trans_tbl = array_flip($trans_tbl);
    return strtr($cadena, $trans_tbl);
}

Initial URL

                                

Initial Description

                                

Initial Title
PHP - unhtmlentities

Initial Tags
html

Initial Language
PHP