I’m working with some JSON based APIs in RPC style and I’m getting this multidimensional arrays after interacting with the APIs via some PHP wrappers:
Array
(
[ok] => 1
[taskgroup] => Array
(
[task_1] => Array
(
[id] => task_1
[name] => Task 1
[url] => /tasks/1/
[description] => Lorem ipsum dolor sit amet...
[img] => http://example.net/mypic1442421.png
[related_tasks] => Array
(
[0] => task_18
)
)
[task_2] => Array
(
[id] => task_2
[name] => Task 2
[url] => /tasks/2/
[description] => Lorem ipsum dolor sit amet...
[img] => http://example.net/mypic1442421.png
[related_tasks] => Array
(
[0] => task_9
[1] => task_23
)
)
)
)
My question is, how can I go through this multi-dimensional arrays? Is there some related methods for this kind of md-array responses? More concretely -to take on some example that could bring light to this thing- how can I print a list of all the images and url like taskArray[][task_n][img] - taskArray[][task_n][url]? –task_n can be any non-sequential alphanumeric value
I tried some recursive methods I found here but without luck, please excuse if I’m asking again the same thing. And excuse the n00bness.
Typically, that array would be processed with code something like this: