note 101347 deleted from function.html-entity-decode by danbrown

From: Date: Sat, 11 Dec 2010 19:49:23 +0000
Subject: note 101347 deleted from function.html-entity-decode by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-174803@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- I think we should make a small change to function unhtmlentities in this manual page to avoid the "Bug #25927 get_html_translation_table calls the ' ' instead of '" 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); } become function unhtmlentities($string) { // replace numeric entities $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); $string = preg_replace('~&#0*([1-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); } we replace '~&#([0-9]+);~e' with '~&#0*([1-9]+);~e' to make sure chr consider the number as decimal rather than octal.

« previous php.notes (#174803) next »