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 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 Link to comment https://forums.phpfreaks.com/topic/79845-solved-foreach-check/#findComment-404335 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.