Home > Backend Development > PHP Tutorial > 这样的xml怎么循环

这样的xml怎么循环

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:53:54
Original
835 people have browsed it

这样的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 />
Copy after login

如何循环这样的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 />
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template