Mecha CMS

Array and object.

Anemon::set()

Set or replace array values recursively.

2.0.02.2.0static
Anemon::set(array &$array, string $key, $value = null, string $NS = '.');

Example:

$array = [
    'foo' => 1,
    'bar' => [
        'baz' => 2,
        'qux' => 3
    ]
];

Anemon::set($array, 'bar.baz', '#');
Anemon::set($array, 'bar.wut', '#');

Result:

$array = [
    'foo' => 1,
    'bar' => [
        'baz' => '#',
        'qux' => 3,
        'wut' => '#'
    ]
];