How such XML loops

Source: Internet
Author: User
SimpleXMLElement Object ([date] = = Array ([0] = Friday (today, Real time: +) [1] = Saturday [2] = Sunday [3] = Monday) [Daypictureurl] = = Array ([0] = = Http://api.            map.baidu.com/images/weather/day/qing.png [1] = Http://api.map.baidu.com/images/weather/day/qing.png [2] = http://api.map.baidu.com/images/weather/day/qing.png [3] = http://api.map.baidu.com/images/w Eather/day/duoyun.png) [Nightpictureurl] = = Array ([0] = Http://api.map.baidu.com/ima ges/weather/night/qing.png [1] = http://api.map.baidu.com/images/weather/night/qing.png [2] =&gt ; http://api.map.baidu.com/images/weather/night/duoyun.png [3] = Http://api.map.baidu.com/images/weather/nigh  t/duoyun.png) [Weather] = Array ([0] = clear [1] = clear [2] = = Sunny Turn cloudy [3] => Cloudy) [wind] = = Array ([0] = North 3-4 [1] = South Wind Breeze [2] = = Southerly breeze [3] = South wind Breeze) [temperature] = = Array ([0] = 24 ~ 9 [1] [2] = ~ [3] = 22 ~ 11)

How to loop such XML data into an array of arrays (' date ' = ' = ', ' daypictureurl ' = ' ', ' nightpictureurl ' = ' = ', ' weather '));


Reply to discussion (solution)

foreach ($xml->date as $i = + $v) {  $res [] = Array (    ' date ' = = $v,    ' daypictureurl ' + $xml daypictureurl[$i],    ' nightpictureurl ' = $xml->nightpictureurl[$i],    ' weather ' = $XM->weather[$ I],  );} Print_r ($res);

Format SimpleXMLElement object? (array) SimpleXMLElement Object

Thanks for all your help.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.