Reputation: 125
Hi I'm using an XML feed and I need to access a loop inside an XML loop.
Basically the xml I have is this:
<properties>
<property>
<images>
<image modified="2012-04-03 19:20:16">http://image.url/</image>
<image modified="2012-04-03 19:20:16">http://image.url/</image>
<image modified="2012-04-03 19:20:16">http://image.url/</image>
<image modified="2012-04-03 19:20:16">http://image.url/</image>
<image modified="2012-04-03 19:20:16">http://image.url/</image>
<image modified="2012-04-03 19:20:16">http://image.url/</image>
</images>
</property>
</properties>
I have this loop:
foreach($xml->property as $property) {
foreach($property->images->image as $key => $value) {
print_r($value);
}
}
But the $value is returning [@attributes] => Array ( [modified] => 2013-10-03 11:53:47
I want the http://image.url/ to be returned.
Any ideas?
Thanks,
Tom
Upvotes: 0
Views: 52
Reputation: 5631
You need to cast the value to string like:
foreach($xml->property as $property) {
foreach($property->images->image as $img) {
$value = (string) $img;
echo $value;
}
}
Upvotes: 2