note 61610 deleted from function.html-entity-decode by nlopess

From: Date: Sat, 20 Jan 2007 22:33:00 +0000
Subject: note 61610 deleted from function.html-entity-decode by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-121967@lists.php.net to get a copy of this message
Note Submitter: buraks78 at gmail dot com ---- The "unhtmlentities" function defined above fails to decode single quotes properly. The issue can be solved by putting double quotes around replacing chr(\\1) with chr("\\1")... 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); }

« previous php.notes (#121967) next »