0
Мне нужно получить некоторые данные из вывода XML:отображения значений массива с simplexml_load_string
[current_condition] => SimpleXMLElement Object
(
[observation_time] => 12:22 PM
[temp_C] => 18
[temp_F] => 64
[weatherCode] => 116
[weatherIconUrl] => SimpleXMLElement Object
(
)
[weatherDesc] => SimpleXMLElement Object
(
)
[windspeedMiles] => 4
[windspeedKmph] => 7
[winddirDegree] => 180
[winddir16Point] => S
[precipMM] => 0.1
[humidity] => 52
[visibility] => 10
[pressure] => 1023
[cloudcover] => 50
)
[weather] => Array
(
[0] => SimpleXMLElement Object
(
[date] => 2013-04-23
[tempMaxC] => 20
[tempMaxF] => 69
[tempMinC] => 7
[tempMinF] => 44
[windspeedMiles] => 5
[windspeedKmph] => 8
[winddirection] => SSW
[winddir16Point] => SSW
[winddirDegree] => 210
[weatherCode] => 113
[weatherIconUrl] => SimpleXMLElement Object
(
)
[weatherDesc] => SimpleXMLElement Object
(
)
[precipMM] => 0.7
)
[1] => SimpleXMLElement Object
(
[date] => 2013-04-24
[tempMaxC] => 25
[tempMaxF] => 76
[tempMinC] => 8
[tempMinF] => 46
[windspeedMiles] => 3
[windspeedKmph] => 5
[winddirection] => NNE
[winddir16Point] => NNE
[winddirDegree] => 24
[weatherCode] => 113
[weatherIconUrl] => SimpleXMLElement Object
(
)
[weatherDesc] => SimpleXMLElement Object
(
)
[precipMM] => 0.3
)
)
Im используя
printf("<p>Current temperature %s and code %s</p>",
$xml->current_condition->temp_C, $xml->current_condition->weatherCode);
для вывода температуры и кода погоды, и работает нормально, это outputing:
Current temperature 18 and code 116
Теперь, как я могу TempMaxC и TempMinC от погоды Array [0] , а также из массива [1]
Благодаря
Вы знаете, что такое цикл? Вы слышали о http://php.net/foreach? Я просто спрашиваю, потому что из вашего вопроса в одиночку неясно, где вы попали в блокпост. – hakre