note 102863 added to function.html-entity-decode
| From: | Vid at osu1 dot php dot net | Date: | Thu, 10 Mar 2011 22:00:28 +0000 |
| Subject: | note 102863 added to function.html-entity-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-177778@lists.php.net to get a copy of this message | ||
I wanted to replace entities for use in a plain text email and html_entity_decode() ignored
'‘' and '’'. I dug around and found some ideas under
get_html_translation_table: http://www.php.net/manual/en/function.get-html-translation-table.php
I took the ideas of 'yes at king22 dot com' - 10-Apr-2007 03:33 and 'Maurizio Siliani
at trident dot it' - 20-Jul-2007 03:43 to make a fast replacement of chars missed by
html_entity_decode().
Here it is:
/* convert html entities to strings */
function htmlEntitiesToStrings($deCodeThis){
return str_replace(
array('‚', 'ƒ', '„',
'…', '†', '‡',
'ˆ', '‰', 'Š',
'‹', 'Œ', '‘', '’',
'“', '”', '•', '–',
'—', '˜', '™', 'š',
'›', 'œ', 'Ÿ'),
array(chr(130), chr(131), chr(132), chr(133), chr(134), chr(135), chr(136), chr(137), chr(138),
chr(139), chr(140), chr(145), chr(146), chr(147), chr(148), chr(149), chr(150), chr(151), chr(152),
chr(153), chr(154), chr(155), chr(156), chr(159)),
html_entity_decode($deCodeThis)
);
}
It works great!
----
Server IP: 69.147.83.197
Probable Submitter: 128.223.36.39
----
Manual Page -- http://www.php.net/manual/en/function.html-entity-decode.php
Edit -- https://master.php.net/note/edit/102863
Del: integrated -- https://master.php.net/note/delete/102863/integrated
Del: useless -- https://master.php.net/note/delete/102863/useless
Del: bad code -- https://master.php.net/note/delete/102863/bad+code
Del: spam -- https://master.php.net/note/delete/102863/spam
Del: non-english -- https://master.php.net/note/delete/102863/non-english
Del: in docs -- https://master.php.net/note/delete/102863/in+docs
Del: other reasons-- https://master.php.net/note/delete/102863
Reject -- https://master.php.net/note/reject/102863
Search -- https://master.php.net/manage/user-notes.php