php xml转array的方法

php xml转array的方法


<pre>
<?php

$responseXml='<xml><appid>12</appid></xml>';
//simplexml_load_string 这个是xml转成对象
$responseObj = simplexml_load_string($responseXml, 'SimpleXMLElement', LIBXML_NOCDATA);
//对象转成数组
$responseObj = json_decode( json_encode( $responseObj),true);
print_r($responseObj);
?>
</pre>

posted @ 2019-11-15 12:13  newmiracle宇宙  阅读(156)  评论(0编辑  收藏  举报