Home  >  Article  >  php教程  >  xml转成数组,原来这么简单!

xml转成数组,原来这么简单!

WBOY
WBOYOriginal
2016-06-07 11:39:211044browse

网上找过xml字符串转成php数组的算法,现在才发现这样一个简单方法!特地分享给大家!
function xml2arr($xml){<br>     $obj  = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);<br>     $json = json_encode($obj);<br>     $arr  = json_decode($json, true);<br>     return $arr;<br> }

AD:真正免费,域名+虚机+企业邮箱=0元

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