$result = [];
foreach ($array as $key => $value) {
if (is_array($value) {
foreach ($value as $k => $v) {
preg_match('#(.*)\.(.*)#', $k, $matches) {
$result[$key] = [$matches[1] => [$matches[2] => $v];
} else {
$result[$key] = [$k => $v];
}
}
} else {
$result[$key] = $value;
}
}