position.php
Table of Contents
Functions
- position() : string
- Returns the position of a value in an array.
Functions
position()
Returns the position of a value in an array.
position(mixed $anyArray, int|string $search[, bool $returnIndex = false ]) : string
This helper wraps the ArangoDB AQL function POSITION(anyArray, search, returnIndex)
which searches for a value in an array and returns either its position or a boolean
indicating whether the value was found.
Example AQL usage:
POSITION([2, 4, 6, 8], 4) // returns 1 (position of 4)
POSITION([2, 4, 6, 8], 4, true) // returns 1 (same as above)
POSITION([2, 4, 6, 8], 5, false) // returns false (not found)
POSITION([2, 4, 6, 8], 5) // returns false (default behavior)
Parameters
- $anyArray : mixed
-
Array expression to search in.
- $search : int|string
-
Value to search for in the array.
- $returnIndex : bool = false
-
When true, returns the index position; when false, returns boolean.
Tags
Return values
string —The formatted AQL expression.