array_shift

array

Removes and returns the first element of an array

Syntax

array_shift(array)

Parameters

array (array)

The array to remove the first element from

Returns

array

A new array with the first element removed

Examples

Input:
[1, 2, 3] | array_shift
Output:
[2, 3]
Input:
["a", "b", "c"] | array_shift
Output:
["b", "c"]

The array_shift() function removes the first element from an array and returns the resulting array without that element.

Usage

This function is useful for removing headers, skipping the first item in a sequence, or processing queues from the front.