note 42185 added to function.html-entity-decode
| From: | daveatcodexwebdotcodotza at rn2 dot php dot net | Date: | Thu, 06 May 2004 19:40:28 +0000 |
| Subject: | note 42185 added to function.html-entity-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-69287@lists.php.net to get a copy of this message | ||
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);
$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["'"] = "'";
}
if (!($opt & 2)) { // Not translating double quotes
// Remove double quote from translation table
unset($trans_tbl["""]);
}
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);
?>
----
Manual Page -- http://www.php.net/manual/en/function.html-entity-decode.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+42185
Delete -- http://master.php.net/manage/user-notes.php?action=delete+42185&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+42185&report=yes
Search -- http://master.php.net/manage/user-notes.php