array_push

array

Adds an element to the end of an array

Syntax

array_push(array, value)

Parameters

array (array)

The array to add an element to

value (any)

The value to add at the end

Returns

array

A new array with the value added at the end

Examples

Input:
[1, 2] | array_push(3)
Output:
[1, 2, 3]
Input:
["a", "b"] | array_push("c")
Output:
["a", "b", "c"]

The array_push() function adds an element to the end of an array, returning a new array with the value appended.

Usage

This function is useful for appending items, building lists incrementally, or adding elements to the end of a sequence.