Extract Part of Array | ARRAY_SUB
Syntax
ARRAY_SUB( [value], [start], [end = ARRAY_LENGTH(value)] )
Parameters
value
The array that the new sub array is created from.
start
The index of where the new sub-array should start.
It should be an integer value.
If the value is not an integer value, it will be coerced into one using the INTEGER method.
If the value is a negative number, it is treated as an index from the end of the array (e.g. -1 is the last item).
end optional
The index of where the new sub-array should end.
Note that the end index is non-inclusive, which means the item at that index will not be included in the result.
It should be an integer value.
If end is not provided or is NULL, UNDEFINED, or an empty string, end is set to the size of the array.
Otherwise, if the value is not an integer value, it will be coerced into one using the INTEGER method.
If the value is a negative number, it is treated as an index from the end of the array (e.g. -1 is the last item).
Return Value
A new ARRAY with the selected entries from the VALUE.Description
Create an ARRAY from a section of another ARRAY.Examples
ARRAY_SUB([], 0, 100) # returns []
ARRAY_SUB([10, 5, 3, 4, 9], 0, 3) # returns [10, 5, 3]
ARRAY_SUB([10, 5, 3, 4, 9], 0) # returns [10, 5, 3, 4, 9]
ARRAY_SUB([10, 5, 3, 4, 9], 0, null) # returns [10, 5, 3, 4, 9]
ARRAY_SUB([10, 5, 3, 4, 9], 3, 5) # returns [3, 4, 9]
ARRAY_SUB([10, 5, 3, 4, 9], 1, 4) # returns [5, 3, 9]
ARRAY_SUB([10, 5, 3, 4, 9], 0, -2) # returns [10, 5, 3]
ARRAY_SUB([10, 5, 3, 4, 9], -2, 5) # returns [3, 4, 9]
ARRAY_SUB(null, 0, 100) # returns []
ARRAY_SUB([10, 5, 3, 4, 9], 5, 1) # returns []