Skip to content
PHP Ecosystem
Explore

ReplaceArrayValue

API reference › yii › helpers › ReplaceArrayValue

classyii\helpers\ReplaceArrayValue
Since2.0.10
Sourceframework/helpers/ReplaceArrayValue.php

Object that represents the replacement of array value while performing ArrayHelper::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',
],
]
PropertyTypeDescriptionDefined by
$valuemixedValue used as replacement. Default: null.ReplaceArrayValue
MethodDescriptionDefined by
__construct()Constructor.ReplaceArrayValue
__set_state() staticRestores class state after using var_export().ReplaceArrayValue
public function __construct(mixed $value)

Constructor.

Parameters

ParameterTypeDescription
$valuemixedValue used as replacement.
public static function __set_state(array $state): yii\helpers\ReplaceArrayValue

Restores class state after using var_export().

Parameters

ParameterTypeDescription
$statearray

Returns

ReplaceArrayValue

Throws

Since

2.0.16

See also