Reputation: 8385
If I have an array like the one below what would be the best way to get all of the ListingCategory
items out of the array so I can use them in an if statement within a foreach?
Array:
Array (
[0] => Array (
[ListingId] => SimpleXMLElement Object ([0] => 532712629)
[ListingCategory] => SimpleXMLElement Object ( [0] => 0350-5748-3400- )
) [1] =>
Upvotes: 1
Views: 59
Reputation: 8733
This will cycle through all array items, and all of the children within each ListingCategory.
foreach($array as $item)
{
foreach($item["ListingCategory"]->children() as $val)
{
doSomething($val);
}
}
Upvotes: 3