php xml转数组

WBOY
WBOYOriginal
2016-06-20 13:03:031014browse

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);

 


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn