note 61610 added to function.html-entity-decode

From: Date: Tue, 07 Feb 2006 23:19:29 +0000
Subject: note 61610 added to function.html-entity-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-103238@lists.php.net to get a copy of this message
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); } ---- Server IP: 64.246.30.37 Probable Submitter: 71.137.93.44 ---- Manual Page -- http://www.php.net/manual/en/function.html-entity-decode.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+61610 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61610&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61610&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61610&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61610&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61610&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61610&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61610&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+61610&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#103238) next »