I have built a DQL that gave me results that look like this:
array:1598 [▼
0 => array:3 [▼
"year" => "2000"
"total" => "750.00"
"name" => "Brand #1"
]
1 => array:3 [▼
"year" => "2000"
"total" => "845.00"
"name" => "Brand #2"
]
..
..
As you can see, there are 1598 sub-arrays in the results. There are 100 brands in total and 16 dates (from 2000 to 2015). total is the total value of orders for a given brand in a given year.
I need to build an array that would look something like this:
array:100 [▼
"Brand #1" => array:3 [▼
"2000" => "750.00"
"2001" => "1750.00"
..
]
"Brand #2" => array:3 [▼
"2000" => "845.00"
"2001" => "945.00"
..
]
..
..
Is it possible to manipulate the initial array so that I achieve the desired array? If so, do you have an idea on how it can be done?
Or maybe it is the database query should be modified to present the results as desired?