云迈博客

您现在的位置是:首页 > 灌水专栏 > 正文

灌水专栏

PHP xml 转数组

刘琦2021-07-30灌水专栏373
publicfunctionindex(){$xml="GeorgeJohnReminderDon'tforgetthemeeting!";

public function index()
{
        $xml = "<note>
<to>George</to>
<from>John</from>
<heading>Reminder</heading>
<body>Don't forget the meeting!</body>
</note>";
        $result = $this->xmltoarray($xml );
        var_dump($result );die();
}
//xml 转数组
function xmltoarray($data){
        $obj = simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA);
        $json = json_encode($obj);
        $arr = json_decode($json, true);
        return $arr;
}

```

发表评论

评论列表

  • 这篇文章还没有收到评论,赶紧来抢沙发吧~