List Info

Thread: note 78371 added to function.htmlentities




note 78371 added to function.htmlentities
user name
2007-10-08 20:29:14
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("&",
"&amp;", $str); 
    $str = str_replace("<",
"&lt;", $str);  
    $str = str_replace(">",
"&gt;", $str);  
    $str = str_replace("'",
"&apos;", $str);   
    $str = str_replace(""",
"&quot;", $str);  
    $str = str_replace("r", "", $str);
    $str = strtr($str,$asc2uni);
    return $str;
}
----
Server IP: 203.16.234.20
Probable Submitter: 203.53.250.30
----
Manual Page -- http://www.php.net/manual/en/function.htmlentities.php

Edit        -- https://master
.php.net/note/edit/78371
Del: integrated  -- h
ttps://master.php.net/note/delete/78371/integrated
Del: useless     -- http
s://master.php.net/note/delete/78371/useless
Del: bad code    -- htt
ps://master.php.net/note/delete/78371/bad+code
Del: spam        -- https:/
/master.php.net/note/delete/78371/spam
Del: non-english -- 
https://master.php.net/note/delete/78371/non-english
Del: in docs     -- http
s://master.php.net/note/delete/78371/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/78371
Reject      -- https://mast
er.php.net/note/reject/78371
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )