How can PHP be used to add the content of multiple files in a directory structure?

To add the content of multiple files in a directory structure using PHP, you can iterate over the files in the directory, read the content of each file, and concatenate it into a single variable. This can be achieved by using functions like opendir(), readdir(), and file_get_contents().

$directory = 'path/to/directory';
$files = scandir($directory);

$content = '';

foreach ($files as $file) {
    if (is_file($directory . '/' . $file)) {
        $content .= file_get_contents($directory . '/' . $file);
    }
}

echo $content;