function array_to_dot_notation(array $array, string $prefix = ''): array { $result = []; foreach ($array as $key => $value) { $newKey = $prefix ? $prefix . '.' . $key : $key; if (is_array($value) && !empty($value)) { $result = array_merge($result, array_to_dot_notation($value, $newKey)); } else { $result[$newKey] = $value; } } return $result; } $config = [ 'app' => [ 'name' => 'My App', 'env' => 'production', 'debug' => false ], 'database' => [ 'host' => 'localhost', 'port' => 3306 ], 'version' => '1.0.0' ]; // Example usage: // $dotNotationConfig = array_to_dot_notation($config); /* Expected result: [ 'app.name' => 'My App', 'app.env' => 'production', 'app.debug' => false, 'database.host' => 'localhost', 'database.port' => 3306, 'version' => '1.0.0' ] */