sergey_sergey Posted March 22, 2010 Report Share Posted March 22, 2010 Подскажите, как в цикле foreach сделать только один проход (показать один результат)?Вот код:foreach ($xml->REPORT->TOWN->FORECAST as $f) {echo ""; } Quote Link to comment Share on other sites More sharing options...
0 Great Rash Posted March 22, 2010 Report Share Posted March 22, 2010 foreach ($xml->REPORT->TOWN->FORECAST as $f) { echo ""; break;}По моему так. Quote Link to comment Share on other sites More sharing options...
0 s0rr0w Posted March 22, 2010 Report Share Posted March 22, 2010 Подскажите, как в цикле foreach сделать только один проход (показать один результат)?echo($xml->REPORT->TOWN->FORECAST);Не нужны там циклы вообще Quote Link to comment Share on other sites More sharing options...
0 LunatiK Posted March 22, 2010 Report Share Posted March 22, 2010 echo($xml->REPORT->TOWN->FORECAST);Не нужны там циклы вообщеа разве это array не выведет ? Quote Link to comment Share on other sites More sharing options...
0 s0rr0w Posted March 22, 2010 Report Share Posted March 22, 2010 а разве это array не выведет ?Нет, это ссылка на первую ноду. Quote Link to comment Share on other sites More sharing options...
0 Int Posted March 23, 2010 Report Share Posted March 23, 2010 Но ведь это же массив, значит надо так?echo $xml->REPORT->TOWN->FORECAST[0] Quote Link to comment Share on other sites More sharing options...
0 s0rr0w Posted March 23, 2010 Report Share Posted March 23, 2010 (edited) Но ведь это же массив, значит надо так?echo $xml->REPORT->TOWN->FORECAST[0]Это не массив. echo ( is_array( $xml->REPORT->TOWN->FORECAST ) ) ; //0 Edited March 23, 2010 by s0rr0w Quote Link to comment Share on other sites More sharing options...
Question
sergey_sergey
Подскажите, как в цикле foreach сделать только один проход (показать один результат)?
Вот код:
Link to comment
Share on other sites
6 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.