I have a heavily nested array which is returned from an API on another website. It looks like this:
Array
(
[data] => Array
(
[0] => Array
(
[pages] => Array
(
[0] => Array
(
[questions] => Array
(
)
)
[1] => Array
(
[questions] => Array
(
[0] => Array
(
[answers] => Array
(
[0] => Array
(
[choice] => 10375872146
What I need is to create an array of the [choice] elements like this:
[choice] => Array (
[0] => 123455,
[1] => 234567,
)
I am able to extract the value from each instance using this code:
$value = ArrayHelper::getValue($arr['data'][0], "pages.1.questions.0.answers.1.choice")
but I don’t know the most efficient mechanism to loop through the nested arrays.
Any help appreciated.
Thanks