国产精品成人VA在线观看,亚洲日韩在线中文字幕综合,亚洲AV电影天堂男人的天堂,久久人人爽人人爽人人av东京热

News新聞

業(yè)界新聞動態(tài)、技術(shù)前沿
Who are we?

您的位置:首頁      樂道系統(tǒng)FAQ      php實現(xiàn)xml轉(zhuǎn)換數(shù)組的方法示例

php實現(xiàn)xml轉(zhuǎn)換數(shù)組的方法示例

標(biāo)簽: 發(fā)布日期:2017-02-03 00:00:00 259

本文實例講述了php實現(xiàn)xml轉(zhuǎn)換數(shù)組的方法。分享給大家供大家參考,具體如下:

<?php
$info = '<?xml version="1.0" encoding="utf-8" ?>
      <data>
        <GeocoderSearchResponse>
          <status>OK</status>
          <result>
            <location>
              <lat>39.94921</lat>
              <lng>116.463619</lng>
            </location>
          <precise>0</precise>
          <confidence>50</confidence>
          <level>腳本</level>
          </result>
        </GeocoderSearchResponse>
        <GeocoderSearchResponse>
          <status>OK</status>
          <result>
            <location>
              <lat>39</lat>
              <lng>116</lng>
            </location>
          <precise>0</precise>
          <confidence>50</confidence>
          <level>腳本123</level>
          </result>
        </GeocoderSearchResponse>
      </data>';
$xml = simplexml_load_string($info);
function xml2array($xmlobject) {
  if ($xmlobject) {
    foreach ((array)$xmlobject as $k=>$v) {
      $data[$k] = !is_string($v) ? xml2array($v) : $v;
    }
    return $data;
  }
}
$data = xml2array($xml);
var_dump($data);
?>