这样的xml怎么循环

WBOY
发布: 2016-06-13 11:53:54
原创
808 人浏览过

这样的xml如何循环

SimpleXMLElement Object<br />(<br />    [date] => Array<br />        (<br />            [0] => 周五(今天, 实时:25)<br />            [1] => 周六<br />            [2] => 周日<br />            [3] => 周一<br />        )<br /><br />    [dayPictureUrl] => Array<br />        (<br />            [0] => http://api.map.baidu.com/images/weather/day/qing.png<br />            [1] => http://api.map.baidu.com/images/weather/day/qing.png<br />            [2] => http://api.map.baidu.com/images/weather/day/qing.png<br />            [3] => http://api.map.baidu.com/images/weather/day/duoyun.png<br />        )<br /><br />    [nightPictureUrl] => Array<br />        (<br />            [0] => http://api.map.baidu.com/images/weather/night/qing.png<br />            [1] => http://api.map.baidu.com/images/weather/night/qing.png<br />            [2] => http://api.map.baidu.com/images/weather/night/duoyun.png<br />            [3] => http://api.map.baidu.com/images/weather/night/duoyun.png<br />        )<br /><br />    [weather] => Array<br />        (<br />            [0] => 晴<br />            [1] => 晴<br />            [2] => 晴转多云<br />            [3] => 多云<br />        )<br /><br />    [wind] => Array<br />        (<br />            [0] => 北风3-4级<br />            [1] => 南风微风<br />            [2] => 南风微风<br />            [3] => 南风微风<br />        )<br /><br />    [temperature] => Array<br />        (<br />            [0] => 24 ~ 9<br />            [1] => 21 ~ 10<br />            [2] => 23 ~ 12<br />            [3] => 22 ~ 11<br />        )<br /><br />)<br />
登录后复制

如何循环这样的xml数据 放到数组里 array(array('date'=>'','dayPictureUrl'=>'','nightPictureUrl'=>'','weather'=>));
------解决方案--------------------
foreach($xml->date as $i=>$v) {<br />  $res[] = array(<br />    'date' => $v,<br />    'dayPictureUrl'=> $xml->dayPictureUrl[$i],<br />    'nightPictureUrl'=> $xml->nightPictureUrl[$i],<br />    'weather' => $xm->weather[$i],<br />  );<br />}<br />print_r($res);<br />
登录后复制

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板