标签:tox ble rto ring ade for code eric func
//数组转xml
function ArrtoXml($arr)
{
if(!is_array($arr) || count($arr) == 0) return ‘‘;
$xml="<xml>";
foreach($arr as $key => $val)
{
if(is_numeric($val))
{
$xml.="<".$key.">".$val."</".$key.">";
}else{
$xml.="<".$key."><![CDATA[".$val."]]></".$key.">";
}
}
$xml.="</xml>";
return $xml;
}
//Xml转数组
function XmlToArr($xml)
{
if($xml == ‘‘) return ‘‘;
libxml_disable_entity_loader(true);
$arr = json_decode(json_encode(simplexml_load_string($xml, ‘SimpleXMLElement‘, LIBXML_NOCDATA)), true);
return $arr;
}
标签:tox ble rto ring ade for code eric func
原文地址:https://www.cnblogs.com/phperyang/p/8758759.html