First pardon me for the title as I couldn't find a proper title for it. Please have a look at the array
Array
(
[0] => Array
(
[0] => 2017
[1] => Array
(
[0] => December
)
)
[1] => Array
(
[0] => 2017
[1] => Array
(
[0] => December
)
)
[2] => Array
(
[0] => 2017
[1] => Array
(
[0] => October
)
)
[3] => Array
(
[0] => 2016
[1] => Array
(
[0] => December
)
)
)
You can see 2017 is duplicated three times and inside 2017 December is duplicated two times. Now I want to get a multi dimensional array from this array that will show the occurrence of 2017 and it's month.
Something like
Array
(
[2017] => 3
[December]=> 2 // should be a nested array of 2017
[October]=> 1 // should be a nested array of 2017
[2016] => 1
[December]=> 1 // should be a nested array of 2016
)
I tried array_count_values and some more custom code but all I managed to get
Array
(
[2017] => 3
[2016] => 1
)
Edit: The months count doesn't has be keyed like this. All I need to know year occurrence and month occurrence under the year
Any help is highly appreciated. Thanks.
[December]key on your desired result is not possible