First Item in List | ARRAY_FIRST

Syntax

ARRAY_FIRST( [value], [default] = null )

Parameters

value
The ARRAY whose first item is being retrieved.

default
A default value that is returned if VALUE is not an ARRAY or if VALUE is empty.

Return Value

The first item in VALUE if it is a non-empty array, or the provided DEFAULT otherwise.

Description

Gets the first item in an array. It is a shorthand for using ARRAY_GET with an index value of 0.

Examples

ARRAY_FIRST([1, 2, 3]) # returns 1
ARRAY_FIRST([]) # returns NULL
ARRAY_FIRST(null) # returns NULL
ARRAY_FIRST([], "DEFAULT") # returns "DEFAULT"
ARRAY_FIRST(null, "DEFAULT") # returns "DEFAULT"