note 91895 added to function.htmlentities
| From: | alonso05 at gmail dot com | Date: | Wed, 01 Jul 2009 04:22:25 +0000 |
| Subject: | note 91895 added to function.htmlentities | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-157738@lists.php.net to get a copy of this message | ||
Hello, I found a great function when you need a way to encode content from the database as numeric
entity references, as thatâs a safe way to use high characters and special characters in an xml
document, like in an RSS feed.
function xml_character_encode($string, $trans='') {
$trans = (is_array($trans)) ? $trans : get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);
foreach ($trans as $k=>$v)
$trans[$k]= "&#".ord($k).";";
return strtr($string, $trans);
}
----
Server IP: 69.147.83.197
Probable Submitter: 189.153.69.201
----
Manual Page -- http://www.php.net/manual/en/function.htmlentities.php
Edit -- https://master.php.net/note/edit/91895
Del: integrated -- https://master.php.net/note/delete/91895/integrated
Del: useless -- https://master.php.net/note/delete/91895/useless
Del: bad code -- https://master.php.net/note/delete/91895/bad+code
Del: spam -- https://master.php.net/note/delete/91895/spam
Del: non-english -- https://master.php.net/note/delete/91895/non-english
Del: in docs -- https://master.php.net/note/delete/91895/in+docs
Del: other reasons-- https://master.php.net/note/delete/91895
Reject -- https://master.php.net/note/reject/91895
Search -- https://master.php.net/manage/user-notes.php