I have 2 arrays like that:
Days Array
Array (
[0] => 2018-01-01
[1] => 2018-02-04
[2] => 2018-02-15
[3] => 2018-04-06
[4] => 2018-04-12
[5] => 2018-04-19
[6] => 2018-04-27
[7] => 2018-07-08
[8] => 2018-08-12
[9] => 2018-08-11
[10] => 2018-08-21
[11] => 2018-10-12
[12] => 2018-10-13
[13] => 2018-10-14
[14] => 2018-10-15
[15] => 2018-11-06
[16] => 2018-12-12
[17] => 2018-12-28
)
Datas Array
Array (
[0] => 4
[1] => 2
[2] => 3
[3] => 2
[4] => 2
[5] => 9
[6] => 7
[7] => 8
[8] => 12
[9] => 21
[10] => 1
[11] => 2
[12] => 13
[13] => 4
[14] => 15
[15] => 6
[16] => 2
[17] => 8
)
I need to group data(adding on to each other of the same month), and group also dates in months.
The expected result is a single array like that:
Array (
[0] => Array ( [month] => 01 [data] => 4)
[1] => Array ( [month] => 02 [data] => 5) /* 2 + 3 = 5 */
...
...
)
Or two array one for months and one for data.
This is not a duplicate. This answer only work if months have only first day multiple times. And is also a lot tricky.