note 78371 deleted from function.htmlentities by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 16:53:08 +0000 |
| Subject: | note 78371 deleted from function.htmlentities by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154906@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous Coward
----
Another version of the xml special characters string conversion, this one also takes care of ascii
chars in range 128 to 255
$asc2uni = Array();
for($i=128;$i<256;$i++){
$asc2uni[chr($i)] = "&#x".dechex($i).";";
}
function XMLStrFormat($str){
global $asc2uni;
$str = str_replace("&", "&", $str);
$str = str_replace("<", "<", $str);
$str = str_replace(">", ">", $str);
$str = str_replace("'", "'", $str);
$str = str_replace("\"", """, $str);
$str = str_replace("\r", "", $str);
$str = strtr($str,$asc2uni);
return $str;
}