note 49403 added to function.get-html-translation-table

From: Date: Wed, 26 Jan 2005 22:05:20 +0000
Subject: note 49403 added to function.get-html-translation-table
Groups: php.notes 
Request: Send a blank email to php-notes+get-84044@lists.php.net to get a copy of this message
In XML, you can't assume that the doctype will include the same character entity definitions as HTML. XML authors may require character references instead. The following two functions use get_html_translation_table() to encode data in numeric references. The second, optional argument can be used to substitute a different translation table. function xmlcharacters($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); } function xml_character_decode($string, $trans='') { $trans=(is_array($trans))? $trans:get_html_translation_table(HTML_ENTITIES, ENT_QUOTES); foreach ($trans as $k=>$v) $trans[$k]= "&#".ord($k).";"; $trans=array_flip($trans); return strtr($string, $trans); } ---- Manual Page -- http://www.php.net/manual/en/function.get-html-translation-table.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49403 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49403&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49403&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49403&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49403&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49403&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49403&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#84044) next »