List Get Index | ARRAY_GET_INDEX

Syntax

ARRAY_GET_INDEX( [value], [search] )

Parameters

value
The array in which the search value is being searched for. If it is not an ARRAY, it will be coerced into one using the ARRAY method.

search
The search value that is being searched for.

Return Value

The index of the first entry matching SEARCH with the VALUE. If SEARCH is not found, -1 is returned. Note that the 0 is the first index in the ARRAY.

Description

Gets the index of a value within an ARRAY.

Examples

ARRAY_GET_INDEX([], 1) # returns -1
ARRAY_GET_INDEX([10, 5, 3], 5) # returns 1
ARRAY_GET_INDEX(["red", "yellow", "blue"], "red") # returns 0
ARRAY_GET_INDEX(["red", "yellow", "blue"], "purple") # returns -1
ARRAY_GET_INDEX([[1, 2, 3], [4, 5, 6], [7, 8, 9]], [7, 8, 9]) # returns 2
ARRAY_GET_INDEX([[1, 2, 3], [4, 5, 6], [7, 8, 9]], [1, 2]) # returns -1
ARRAY_GET_INDEX([["a" => 1]], ["a" => 1]) # returns 0
ARRAY_GET_INDEX([["a" => 1]], ["a" => 2]) # returns -1
ARRAY_GET_INDEX(null, 1) # returns 1
ARRAY_GET_INDEX([1, 2, 3, 2, 4], 2) # returns 1
ARRAY_GET_INDEX("a", "a") # returns 0