首页 > 编程语言 > 详细

分享一个解析XML成为php数组的方法

时间:2015-01-06 09:45:45      阅读:176      评论:0      收藏:0      [点我收藏+]
原文:分享一个解析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;
   }
   
?>

  

分享一个解析XML成为php数组的方法

原文:http://www.cnblogs.com/lonelyxmas/p/4205191.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!