---
title: "Merge ViewHelper <f:merge>"
manual: "Fluid Explained"
version: "main"
permalink: "https://docs.typo3.org/permalink/fluid:typo3fluid-fluid-merge"
source: "ViewHelpers/Fluid/Merge.rst"
rendered: "2026-10-08T14:12:40+00:00"
---

# Merge ViewHelper `<f:merge>` {#typo3fluid-fluid-merge}

> [!NOTE]
> This reference is part of the documentation of Fluid Standalone.
> If you are working with Fluid in TYPO3 CMS, please refer to
> [TYPO3's ViewHelper reference](https://docs.typo3.org/other/typo3/view-helper-reference/14.3/en-us/Global/Merge.html) instead.

The MergeViewHelper merges two arrays into one, optionally recursively.

It works similar to the PHP functions array_merge() and array_merge_recursive(),
depending on the value of the "recursive" argument.

## Example {#example}

### Simple merge {#simple-merge}

```php
<f:merge array="{0: 'a', 1: 'b'}" with="{1: 'x', 2: 'c'}" />

```

Result:

```php
{0: 'a', 1: 'x', 2: 'c'}

```

### Recursive merge {#recursive-merge}

```php
<f:merge array="{foo: {bar: 'baz'}}" with="{foo: {qux: 'value'}}" recursive="true" />

```

Result:

```php
{foo: {bar: 'baz', qux: 'value'}}

```

### Inline notation {#inline-notation}

```php
{f:variable(name: 'myArray', value: {foo: 1})}
{myArray -> f:merge(with: {bar: 2})}

```

Result:

```php
{foo: 1, bar: 2}
```

Go to the source code of this ViewHelper: [MergeViewHelper.php (GitHub)](https://github.com/TYPO3/Fluid/blob/main/src/ViewHelpers/MergeViewHelper.php).

**Arguments**

The following arguments are available for the merge ViewHelper:

-   **array**

    -   *Type:* array

    The array to merge into

-   **recursive**

    -   *Type:* boolean
    -   *Default:* false

    Whether to merge arrays recursively

-   **with**

    -   *Type:* array

    Array to be merged
