ReplaceArrayValue
API reference › yii › helpers › ReplaceArrayValue
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', ],]Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$value | mixed | Value used as replacement. Default: null. | ReplaceArrayValue |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Constructor. | ReplaceArrayValue |
__set_state() static | Restores class state after using var_export(). | ReplaceArrayValue |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(mixed $value)Constructor.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | mixed | Value used as replacement. |
__set_state()
Section titled “__set_state() ”public static function __set_state(array $state): yii\helpers\ReplaceArrayValueRestores class state after using var_export().
Parameters
| Parameter | Type | Description |
|---|---|---|
$state | array |
Returns
Throws
yii\base\InvalidConfigException: when $state property does not containvalueparameter
Since
2.0.16
See also