Home > Backend Development > PHP Tutorial > php xml转数组

php xml转数组

WBOY
Release: 2016-06-20 13:03:03
Original
1024 people have browsed it

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);
Copy after login

 


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template