I have an array of following structure
Array
(
[id-on56R] => Array
(
[doc_num] => 121
[id-on56R] => Array
(
[error_count_low] => 0
[sum_my_count] => 0
[data] => Array
(
[0] => Array
(
[id] => xx9238-333
[total] => 9287
)
[1] => Array
(
[id] => tty299-992228
[total] => 7441
)
[2] => Array
(
[id] => zeyyt-003088
[total] => 28741
)
)
)
)
)
I want to extract the subarray data with its keys (id, total) and their values.
[0] => Array
(
[id] => xx9238-333
[total] => 9287
)
[1] => Array
(
[id] => tty299-992228
[total] => 7441
)
[2] => Array
(
[id] => zeyyt-003088
[total] => 28741
)
I tried solutions in this answer but nothing worked for me. Then, I tried to flatten the array, using the following code:
$result = array();
array_walk_recursive($buckets,function($v) use (&$result){ $result[] = $v; });
But the above code is removing the keys, which is not what I want.