append
Add items to the end of an array
Definition
array[any] append(array[any] $array, any *$items)
Appends *$items
to the end of $array
and returns the resulting array.
Parameters
array $array
The array to be extended.
any *$items
Any amount of arguments of any type to be added to the end of the $array
.
Returns
array
The array with $items
appended to the end of $array
.
Examples
{
a: append(`[]`, `0`),
b: append(`[0]`, `"abc"`),
c: append(`[0, "abc"]`, `null`),
d: append(`[0, "abc", null]`, `[true, false]`),
e: append(`[0, "abc", null]`, `true`, `false`),
f: append(`1`, `[]`) // Error
}
{
"a": [0],
"b": [0, "abc"],
"c": [0, "abc", null],
"d": [0, "abc", null, [true, false]],
"e": [0, "abc", null, true, false]
}
Updated about 1 year ago