标签:转换 string print bsp join lex span pap struct
<?php $s=join(,file(‘httpapi.elong.comxmlv2.0hotelcn0132701501.xml‘)); $result = xml_to_array($s); print_r($result); /*函数*/ function xml_to_array($xml) { $array = (array)(simplexml_load_string($xml)); foreach ($array as $key=$item){ $array[$key] = struct_to_array((array)$item); } return $array; } function struct_to_array($item) { if(!is_string($item)) { $item = (array)$item; foreach ($item as $key=$val){ $item[$key] = struct_to_array($val); } } return $item; }
标签:转换 string print bsp join lex span pap struct
原文地址:http://www.cnblogs.com/renxing123/p/6008895.html