SimpleXMLElement Object( [date] => Array ( [0] => 周五(今天, 实时:25) [1] => 周六 [2] => 周日 [3] => 周一 ) [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/weather/day/duoyun.png ) [nightPictureUrl] => Array ( [0] => http://api.map.baidu.com/images/weather/night/qing.png [1] => http://api.map.baidu.com/images/weather/night/qing.png [2] => http://api.map.baidu.com/images/weather/night/duoyun.png [3] => http://api.map.baidu.com/images/weather/night/duoyun.png ) [weather] => Array ( [0] => 晴 [1] => 晴 [2] => 晴转多云 [3] => 多云 ) [wind] => Array ( [0] => 北风3-4级 [1] => 南风微风 [2] => 南风微风 [3] => 南风微风 ) [temperature] => Array ( [0] => 24 ~ 9 [1] => 21 ~ 10 [2] => 23 ~ 12 [3] => 22 ~ 11 ))
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);将SimpleXMLElement Object格式化? (array) SimpleXMLElement Object
谢谢大家的热心帮忙
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号