So I have an array that looks like this:
[98] => Array
(
[City] => Caracas
[Country] => Venezuela
[Continent] => Latin America
)
[99
I think you just need to loop in your array and create a new one using some values as keys and some other as value, for example
$new_array = array();
foreach($array as $val)
{
$new_array[$val['Continent']][$val['Country']] = array('City' => $val['City']);
}
Live Sample
$array = array(
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',
)
);
$newArray = array();
foreach ($array as $row)
{
$newArray[$row['Continent']][$row['Country']][] = $row['City'];
}
print_r($newArray);