# Merge HTML Files in PHP

> Merge HTML files in PHP with Aspose.Slides for PHP via Java and save the combined content as HTML.

Source: https://products.aspose.com/slides/php-java/merger/html-to-html/
Updated: 2026-07-20



## Merge HTML to HTML using Aspose.Slides

[**Aspose.Slides for PHP via Java**](/slides/php-java/) can import content from multiple HTML files into a `Presentation` and export the resulting slides as a single HTML document. The imported text, images, and supported formatting become presentation content before the final HTML export.

## Merge HTML to HTML in PHP

Using [**Aspose.Slides for PHP via Java**](/slides/php-java/), you can import two HTML files and save their combined presentation content as HTML with a few lines of PHP code.

### PHP code for merging HTML to HTML

```php
$presentation = new Presentation();
try {
    $presentation->getSlides()->removeAt(0);

    $firstHtmlContent = file_get_contents("file1.html");
    $presentation->getSlides()->addFromHtml($firstHtmlContent);

    $secondHtmlContent = file_get_contents("file2.html");
    $presentation->getSlides()->addFromHtml($secondHtmlContent);

    $presentation->save("merged.html", SaveFormat::Html5);
} finally {
    $presentation->dispose();
}
```

## How to merge HTML files in PHP

Install **Aspose.Slides for PHP via Java**. See [**Installation**](https://docs.aspose.com/slides/php-java/installation/).

Configure Aspose.Slides in your PHP project.

Create a `Presentation` instance and remove its default slide.

Read the HTML files with `file_get_contents` and import their content with `addFromHtml`.

Call `save` with the output file path and `SaveFormat::Html5`.

## Merge Other Files
