标签:str UNC fun sim foreach oar libxml div ret
xmlToArray方法,供参考
public function xmlToArray($xml) { libxml_disable_entity_loader(true); $xmlstring = simplexml_load_string($xml,‘SimpleXMLElement‘,LIBXML_NOCDATA); $val = json_decode(json_encode($xmlstring),true); // libxml_disable_entity_loader(true); // $result = json_decode(json_encode(simplexml_load_string($xml, ‘SimpleXMLElement‘, LIBXML_NOCDATA)), true); return $val; }
arrayToXml方法,供参考
public function arrayToXml($arr) { $xml = "<xml>"; foreach ($arr as $key=>$val){ if(is_array($val)){ $xml.="<".$key.">".arrayToXml($val)."</".$key.">"; }else{ $xml.="<".$key.">".$val."</".$key.">"; } } $xml.="</xml>"; return $xml ; }
标签:str UNC fun sim foreach oar libxml div ret
原文地址:https://www.cnblogs.com/lyzaidxh/p/10270557.html