I have an array that looks like this:
[98] => Array
(
[City] => Caracas
[Country] => Venezuela
[Continent] => Latin America
)
[99] => Array
(
[City] => Cairo
[Country] => Egypt
[Continent] => Middle East
)
[105] => Array
(
[City] => Abu Dhabi
[Country] => United Arab Emirates
[Continent] => Middle East
)
[106] => Array
(
[City] => Dubai
[Country] => United Arab Emirates
[Continent] => Middle East
)
[107] => Array
(
[City] => Montreal
[Country] => Canada
[Continent] => North America
)
I am trying to group this array into a new multi-dimensional array structure, so that it outputs something like:
Continent
- Country Name
-- Cities under Every Country
Exact desired result:
array (
'Latin America' =>
array (
'Venezuela' =>
array (
0 => 'Caracas',
),
),
'Middle East' =>
array (
'Egypt' =>
array (
0 => 'Cairo',
),
'United Arab Emirates' =>
array (
0 => 'Abu Dhabi',
1 => 'Dubai',
),
),
'North America' =>
array (
'Canada' =>
array (
0 => 'Montreal',
),
),
)