标签:
原文:分享一个解析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 xmlToArray($xml){
$arr_xml = (array)$xml;
foreach($arr_xml as $key=>$item){
if(is_object($item) || is_array($item)){
$arr_xml[$key] = xmlToArray($item);
}
}
return $arr_xml;
}
?>
标签:
原文地址:http://www.cnblogs.com/lonelyxmas/p/4205191.html