overlay.php
Table of Contents
Functions
- overlay() : array<string|int, mixed>
- Lays one array over another, the way a configuration file is read: what the second says for a key is what applies to that key.
Functions
overlay()
Lays one array over another, the way a configuration file is read: what the second says for a key is what applies to that key.
overlay(array<string|int, mixed> $base, array<string|int, mixed> $over) : array<string|int, mixed>
- Tables (associative arrays) are merged key by key, recursively: naming one setting keeps every other one the base provides.
- Lists are replaced whole: a list is a statement, not a contribution.
[ 'akismet' ]over fifteen plugins gives one plugin, and[]gives none. - Any other value, and a table laid over something that is not one, replaces what was there.
- Keys the second array does not mention are left as they are; keys only it has are added.
This is the difference with its neighbours. deepMerge() appends to integer-keyed arrays,
so an overriding list could only ever add to the base, never shorten it.
array_replace_recursive() replaces lists index by index: [ 'x' ] over [ 'a' , 'b' , 'c' ]
gives [ 'x' , 'b' , 'c' ], a list nobody wrote.
An empty array counts as a list (array_is_list()), so it replaces: it is how an override says "none".
Parameters
- $base : array<string|int, mixed>
-
The defaults.
- $over : array<string|int, mixed>
-
What is declared on top of them.
Tags
Return values
array<string|int, mixed> —The base with the declarations applied.