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

From: Date: Sat, 11 Dec 2010 19:49:23 +0000
Subject: note 101348 deleted from function.html-entity-decode by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-174804@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- Sorry the function should be function unhtmlentities($string) { // replace numeric entities $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); $string = preg_replace('~&#0*([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); } ~&#0*([0-9]+);~e rather than ~&#0*([1-9]+);~e

« previous php.notes (#174804) next »