note 42185 deleted from function.html-entity-decode by aidan

From: Date: Tue, 14 Sep 2004 07:56:09 +0000
Subject: note 42185 deleted from function.html-entity-decode by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-76654@lists.php.net to get a copy of this message
Note Submitter: dave at codexweb dot co dot za ---- Well, I needed this at some stage, so it may be of some use to others with PHP<4.3.0. Here is a working replica of html_entity_decode(): <?php if (!function_exists('html_entity_decode')) { function html_entity_decode ($string, $opt = ENT_COMPAT) { $trans_tbl = get_html_translation_table (HTML_ENTITIES, $opt); $trans_tbl = array_flip ($trans_tbl); if ($opt & 1) { // Translating single quotes // Add single quote to translation table; // doesn't appear to be there by default $trans_tbl["&apos;"] = "'"; } if (!($opt & 2)) { // Not translating double quotes // Remove double quote from translation table unset($trans_tbl["&quot;"]); } return strtr ($string, $trans_tbl); } } // Just to be safe ;o) if (!defined("ENT_COMPAT")) define("ENT_COMPAT", 2); if (!defined("ENT_NOQUOTES")) define("ENT_NOQUOTES", 0); if (!defined("ENT_QUOTES")) define("ENT_QUOTES", 3); ?>

« previous php.notes (#76654) next »