php xml转数组

原创
2016-06-20 13:03:03 720浏览

php xml转数组

开发微信返回的是的xml感觉会比较齐全。但是我需要的是数组。那么我得把xml转换为数组。php已经给我们有许多的内设函数了。所以我们只要调用就OK了。先用 simplexml_load_string 格式化一下 。

然后在用 json_decode 转换为数组。php xml转数组例子

  $str = '';
  $res = @simplexml_load_string($str,NULL,LIBXML_NOCDATA);
  $res = json_decode(json_encode($res),true);
  print_r($res);


声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。