note 96324 added to function.html-entity-decode

From: Date: Sat, 20 Feb 2010 13:54:59 +0000
Subject: note 96324 added to function.html-entity-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-166211@lists.php.net to get a copy of this message
If you want to convert Hex or Decimal Html entities into UTF-8 HTML entities : Example : é into é OR é into é Use this function : function numeric_entities($string){ $mapping_hex = array(); $mapping_dec = array(); foreach (get_html_translation_table(HTML_ENTITIES, ENT_QUOTES) as $char => $entity){ $mapping_hex[html_entity_decode($entity,ENT_QUOTES,"UTF-8")] = '&#x' . strtoupper(dechex(ord(html_entity_decode($entity,ENT_QUOTES)))) . ';'; $mapping_dec[html_entity_decode($entity,ENT_QUOTES,"UTF-8")] = '&#' . ord(html_entity_decode($entity,ENT_QUOTES)) . ';'; } $string = str_replace(array_values($mapping_hex),array_keys($mapping_hex) , $string); $string = str_replace(array_values($mapping_dec),array_keys($mapping_dec) , $string); return $string; } ---- Server IP: 69.147.83.197 Probable Submitter: 89.90.136.140 ---- Manual Page -- http://www.php.net/manual/en/function.html-entity-decode.php Edit -- https://master.php.net/note/edit/96324 Del: integrated -- https://master.php.net/note/delete/96324/integrated Del: useless -- https://master.php.net/note/delete/96324/useless Del: bad code -- https://master.php.net/note/delete/96324/bad+code Del: spam -- https://master.php.net/note/delete/96324/spam Del: non-english -- https://master.php.net/note/delete/96324/non-english Del: in docs -- https://master.php.net/note/delete/96324/in+docs Del: other reasons-- https://master.php.net/note/delete/96324 Reject -- https://master.php.net/note/reject/96324 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#166211) next »