I am trying to figure out how i can loop through this stdClass Object. I am trying to get the path value of each contents array item [0]-[?].
The Object array looks like this:
stdClass Object
(
[hash] => zzzzzzzzzzzzzzzzzzzzzzzzzzzz
[revision] => 22
[rev] => 161f5f4043
[thumb_exists] =>
[bytes] => 0
[modified] => Sun, 23 Mar 2014 18:05:38 +0000
[path] => /Camera Uploads
[is_dir] => 1
[icon] => folder_photos
[root] => dropbox
[contents] => Array
(
[0] => stdClass Object
(
[revision] => 47
[rev] => 2f1f5f4043
[thumb_exists] => 1
[bytes] => 3212196
[modified] => Sun, 23 Mar 2014 18:07:05 +0000
[client_mtime] => Wed, 05 Feb 2014 19:10:14 +0000
[path] => /Camera Uploads/2014-02-05 14.10.13.jpg
[is_dir] =>
[icon] => page_white_picture
[root] => dropbox
[mime_type] => image/jpeg
[size] => 3.1 MB
)
[1] => stdClass Object
(
etc etc...
Currently i am trying the following code to loop:
line 75: print_r ($dropbox->GetMetadata($file->path));
line 77: foreach ($dropbox->GetMetadata($file->path) as $arr) {
line 78: foreach ($arr as $obj) {
line 79: $path = $obj->path;
line 80: echo $path;
line 81: }
line 82: }
But i keep getting this error:
( ! ) Warning: Invalid argument supplied for foreach() in
C:\wamp\www\test\sample.php on line 78
Call Stack
# Time Memory Function Location
1 0.0011 157592 {main}( ) ..\sample.php:0
var_dump($arr);
and you'll see. Btw,$arr
is a misleading variable name. It should be$property
as you are iterating over an object's properties – hek2mgl Mar 30 at 0:59