Look at https://gist.github.com/jimgwhit/cbbe5bb0d2556fdc7e37a86d3630239c
Has an example of a nested array.
Hello,
I have this array.
$test = [
[
'id' => 2,
'results' => [
'average' => 3.5,
'note' => 1.5,
]
],
[
'id' => 3,
'results' => [
[
'average' => 4.5,
'note' => 2.5,
],
[
'average' => 5.5,
'note' => 3.5,
]
]
]
];
I'd like to retrieve only the average values and format them as a collection of objects.
It works fine loops, but I wonder if there is another way to do with the array helpers.
I think that the first step is to extract the average values, I have tried with Arr::pluck($test, 'results.average'), but it doesn't work, it only retrieves the first value.
Any idea to do that ?
Thanks for your advice.
V
Please or to participate in this conversation.