note 42361 added to function.htmlentities
| From: | xmonteroatdsitelecomdotcom at rn2 dot php dot net | Date: | Thu, 13 May 2004 13:03:30 +0000 |
| Subject: | note 42361 added to function.htmlentities | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-69557@lists.php.net to get a copy of this message | ||
The function posted on nov/2003 has a slight problem.
If you get an & from the conversion you might get it converted again. For example, if you expect
an a acute to be á then perhaps you get á which does not render the tilded
a but its expanded entity. This (perhaps) could depend on the order of the returned array by the
table (i don't know).
To get the desired result, simply substitute the str_replace function with strtr:
function myhtmlentities($str)
{
$tbl=get_html_translation_table(HTML_ENTITIES);
unset ($tbl["<"]);
unset ($tbl[">"]);
unset ($tbl["'"]);
unset ($tbl['"']);
$tbl[""]=""";
$tbl[""]=""";
$tbl["
"]="...";
$tbl[""]="-";
$tbl["»"]="»";
$tbl["«"]="«";
return strtr( $str, $tbl );
}
----
Manual Page -- http://www.php.net/manual/en/function.htmlentities.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+42361
Delete -- http://master.php.net/manage/user-notes.php?action=delete+42361&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+42361&report=yes
Search -- http://master.php.net/manage/user-notes.php