# ReplaceArrayValue

> Object that represents the replacement of array value while performing yii\helpers\ArrayHelper::merge().

[API reference](/docs/api/index.md) › [yii](/docs/api/yii/index.md) › [helpers](/docs/api/yii/helpers/index.md) › ReplaceArrayValue

| class | `yii\helpers\ReplaceArrayValue` |
| --- | --- |
| Since | 2.0.10 |
| Source | [`framework/helpers/ReplaceArrayValue.php`](https://github.com/yiisoft/yii2/blob/22.0/framework/helpers/ReplaceArrayValue.php#L60) |

Object that represents the replacement of array value while performing [`ArrayHelper::merge()`](/docs/api/yii/helpers/basearrayhelper/index.md#method-merge).

Usage example:

```
$array1 = [
    'ids' => [
        1,
    ],
    'validDomains' => [
        'example.com',
        'www.example.com',
    ],
];

$array2 = [
    'ids' => [
        2,
    ],
    'validDomains' => new \yii\helpers\ReplaceArrayValue([
        'yiiframework.com',
        'www.yiiframework.com',
    ]),
];

$result = \yii\helpers\ArrayHelper::merge($array1, $array2);
```

The result will be

```
[
    'ids' => [
        1,
        2,
    ],
    'validDomains' => [
        'yiiframework.com',
        'www.yiiframework.com',
    ],
]
```

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-value"></span>`$value` | `mixed` | Value used as replacement. Default: `null`. | `ReplaceArrayValue` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Constructor. | `ReplaceArrayValue` |
| [`__set_state()`](#method-__set_state) static | Restores class state after using `var_export()`. | `ReplaceArrayValue` |

## Method details

### __construct() <span id="method-__construct"></span>

```php
public function __construct(mixed $value)
```

Constructor.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `mixed` | Value used as replacement. |

### __set_state() <span id="method-__set_state"></span>

```php
public static function __set_state(array $state): yii\helpers\ReplaceArrayValue
```

Restores class state after using `var_export()`.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$state` | `array` |  |

**Returns**

[`ReplaceArrayValue`](/docs/api/yii/helpers/replacearrayvalue/index.md)

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): when $state property does not contain `value` parameter

**Since**

2.0.16

**See also**

- <https://www.php.net/manual/en/function.var-export.php>