note 37721 deleted from function.htmlentities by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 17:09:48 +0000 |
| Subject: | note 37721 deleted from function.htmlentities by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154949@lists.php.net to get a copy of this message | ||
Note Submitter: root[noSPAM]cyberdark.net
----
A little function that may help someone. Is useful where, FE, someone writes a text through a
content management panel and is also able to put html (bolds, italics,...), so we don't want to
convert html tags but all the rest. The code offers a few examples of extra entities.
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 str_replace(array_keys($tbl),array_values($tbl),$str);
}