note 42361 deleted from function.htmlentities by tomsommer
| From: | tomsommer@php.net | Date: | Thu, 13 May 2004 20:19:45 +0000 |
| Subject: | note 42361 deleted from function.htmlentities by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-69582@lists.php.net to get a copy of this message | ||
Note Submitter: xmontero at dsitelecom dot com
----
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 );
}