setArrayValue.php
Table of Contents
Functions
- setArrayValue() : array<string|int, mixed>
- Sets a value in a flat associative array using a single key.
Functions
setArrayValue()
Sets a value in a flat associative array using a single key.
setArrayValue(array<string|int, mixed> $document, string $key, mixed $value) : array<string|int, mixed>
This helper function assigns the given value to the specified key in the provided array. It does not support nested keys or separators.
The array is returned with the updated value, leaving the original array unmodified if passed by value.
Parameters
- $document : array<string|int, mixed>
-
The associative array to modify.
- $key : string
-
The key at which to set the value.
- $value : mixed
-
The value to assign to the key.
Tags
Return values
array<string|int, mixed> —The modified array with the new or updated key/value pair.