nth.php
Table of Contents
Functions
- nth() : string
- Get the element at the given position in an array.
Functions
nth()
Get the element at the given position in an array.
nth(mixed $anyArray, int $position) : string
This helper wraps the ArangoDB AQL function NTH(anyArray, position) which
returns the element at the specified zero-based position in the array.
If the position is out of bounds, it returns null.
Note: Negative positions are not supported in ArangoDB AQL.
Example AQL usage:
NTH([2, 4, 6, 8], 0) // returns 2 (first element)
NTH([2, 4, 6, 8], 2) // returns 6 (third element)
NTH([2, 4, 6, 8], 10) // returns null (out of bounds)
Parameters
- $anyArray : mixed
-
Array expression to get element from.
- $position : int
-
Zero-based position of the element to retrieve.
Tags
Return values
string —The formatted AQL expression.