note 88169 added to function.htmlentities
| From: | gunter | Date: | Tue, 13 Jan 2009 18:48:05 +0000 |
| Subject: | note 88169 added to function.htmlentities | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-149148@lists.php.net to get a copy of this message | ||
Had a heck of a time to get my rss entities right. using htmlentities didn't work and using
html_entity_decode didn't work either. Ended up writing a custom function to encode and decode.
It might still need some work but I thought to share it because I couldn't find anything on the
net. Always open for suggestions to improve it! Here it is:
$entity_custom_from = false;
$entity_custom_to = false;
function html_entity_decode_encode_rss($data) {
global $entity_custom_from, $entity_custom_to;
if(!is_array($entity_custom_from) || !is_array($entity_custom_to)){
$array_position = 0;
foreach (get_html_translation_table(HTML_ENTITIES) as $key => $value) {
//print("<br />key: $key, value: $value <br />\n");
switch ($value) {
// These ones we can skip
case ' ':
break;
case '>':
case '<':
case '"':
case ''':
case '&':
$entity_custom_from[$array_position] = $key;
$entity_custom_to[$array_position] = $value;
$array_position++;
break;
default:
$entity_custom_from[$array_position] = $value;
$entity_custom_to[$array_position] = $key;
$array_position++;
}
}
}
return str_replace($entity_custom_from, $entity_custom_to, $data);
}
----
Server IP: 216.235.13.26
Probable Submitter: 137.186.214.115
----
Manual Page -- http://www.php.net/manual/en/function.htmlentities.php
Edit -- https://master.php.net/note/edit/88169
Del: integrated -- https://master.php.net/note/delete/88169/integrated
Del: useless -- https://master.php.net/note/delete/88169/useless
Del: bad code -- https://master.php.net/note/delete/88169/bad+code
Del: spam -- https://master.php.net/note/delete/88169/spam
Del: non-english -- https://master.php.net/note/delete/88169/non-english
Del: in docs -- https://master.php.net/note/delete/88169/in+docs
Del: other reasons-- https://master.php.net/note/delete/88169
Reject -- https://master.php.net/note/reject/88169
Search -- https://master.php.net/manage/user-notes.php