problem assigning array to variable
Posted
by
shaw2thefloor
on Stack Overflow
See other posts from Stack Overflow
or by shaw2thefloor
Published on 2011-01-09T12:48:40Z
Indexed on
2011/01/09
12:53 UTC
Read the original article
Hit count: 164
Hi. I'm sure this is a simple one. I have an array in a simplexml object. When I try to assign the array to a variable, it only assigns the first index of the array. How can I get it to assign the whole array. This is my code.
$xml = simplexml_load_string(FlickrUtils::getMyPhotos("flickr.photos.search", $_SESSION['token']));
$photosArray = $xml->photos;
//$photosArray = $xml->photos->photo;
//echo gettype($photosArray);
print_r($photosArray);
This is the result of the print_r($photosArray);
SimpleXMLElement Object ( [@attributes] => Array ( [page] => 1 [pages] => 1 [perpage] => 100 [total] => 4 )
[photo] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => 5335626037
[owner] => 57991585@N02
[secret] => bd66f06b49
[server] => 5210
[farm] => 6
[title] => 1
[ispublic] => 1
[isfriend] => 0
[isfamily] => 0
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => 5336238676
[owner] => 57991585@N02
[secret] => 898dffa011
[server] => 5286
[farm] => 6
[title] => 2
[ispublic] => 1
[isfriend] => 0
[isfamily] => 0
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => 5335625381
[owner] => 57991585@N02
[secret] => 60a0c84597
[server] => 5126
[farm] => 6
[title] => 4
[ispublic] => 1
[isfriend] => 0
[isfamily] => 0
)
)
[3] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => 5335625195
[owner] => 57991585@N02
[secret] => 49348c1e8b
[server] => 5126
[farm] => 6
[title] => 3
[ispublic] => 1
[isfriend] => 0
[isfamily] => 0
)
)
)
)
Thanks for youe help!
© Stack Overflow or respective owner