diff --git a/reference/strings/functions/html-entity-decode.xml b/reference/strings/functions/html-entity-decode.xml index 07997bd545..f44516e72f 100644 --- a/reference/strings/functions/html-entity-decode.xml +++ b/reference/strings/functions/html-entity-decode.xml @@ -1,5 +1,5 @@ - + @@ -78,6 +78,10 @@ echo $b; // I'll "walk" the dog now // For users prior to PHP 4.3.0 you may do this: function unhtmlentities($string) { + // replace numeric entities + $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); + $string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string); + // replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl); return strtr($string, $trans_tbl);