Array
(
[0] => Array
(
[name] => Россия
[city] => Москва
)
[1] => Array
(
[name] => Россия
[city] => Санкт-Петербург
)
[2] => Array
(
[name] => Россия
[city] => Санкт-Петербург
)
[3] => Array
(
[name] => Белоруссия
[city] => Минск
)
[4] => Array
(
[name] => Белоруссия
[city] => Брест
)
)
$a = [...];
$b = [];
foreach ($a as $item) {
if (!array_key_exists($item['name'], $b)) {
$b[$item['name']] = [];
}
if (!in_array($item['city'], $b[$item['name']])) {
$b[$item['name']][] = $item['city'];
}
}