Home  >  Article  >  php教程  >  PHP如何将XML转成数组

PHP如何将XML转成数组

WBOY
WBOYOriginal
2016-06-07 11:41:421475browse

PHP如何将XML转成数组
如果你使用 curl 获取的 xml data
$xml = simplexml_load_string($data);
$data['tk'] = json_decode(json_encode($xml),TRUE);

如果是直接获取 URL 数据的话
$xml = simplexml_load_file($data);
$data['tk'] = json_decode(json_encode($xml),TRUE);

先把 simplexml 对象转换成 json,再将 json 转换成数组。

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