原文:分享一个解析XML成为php数组的方法 <?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ $xml = 'site_1.xml'; $myxml = simplexml_load_file($xml); // print_r($myxml); print_r(xmlToArray($myxml)); function xmlToArra…
这里提供一个类来将XML转换为PHP数组,下面是类的代码 <?php/** * XML2Array: A class to convert XML to array in PHP * It returns the array which can be converted back to XML using the Array2XML script * It takes an XML string or a DOMDocument object as an input. * * See Array…
//将xml字符串转换为数组 public function xmlToArray($xml){ $array_data = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true); return $array_data; } /* * 对要发送到微信统一下单接口的数据进行签名 */ public function getSign($Obj,$apiKey){…