ziarkaen Posted December 2, 2007 Share Posted December 2, 2007 hi, I'm analysing each "Item" part of an object created using "simplexml_load_file()" with a foreach loop, but I want to check at least one "Item" component exists before doing this. Pseudo and real code follow: $xml = simplexml_load_file($urlfile); foreach($xml->SearchResult->ItemArray->Item as $item) { <<do stuff on $item>> } any help is......helpful lol thanks ben Quote Link to comment https://forums.phpfreaks.com/topic/79845-solved-foreach-check/ Share on other sites More sharing options...
ziarkaen Posted December 2, 2007 Author Share Posted December 2, 2007 solved using: if($xmldata->SearchResult->ItemArray){ <<do stuff>> } else{ <<don't do stuff>> } ben Quote Link to comment https://forums.phpfreaks.com/topic/79845-solved-foreach-check/#findComment-404335 Share on other sites More sharing options...
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.