unshift.php
Table of Contents
Functions
- unshift() : string
- Prepend a value to the beginning of an array.
Functions
unshift()
Prepend a value to the beginning of an array.
unshift(mixed $anyArray, mixed $value[, bool $unique = false ]) : string
This helper wraps the ArangoDB AQL function UNSHIFT(anyArray, value, unique)
which adds a value to the beginning of an array. If unique is true, the value
is only added if it's not already present in the array.
Example AQL usage:
UNSHIFT([2, 4, 6], 1) // returns [1, 2, 4, 6]
UNSHIFT([2, 4, 6], 4) // returns [4, 2, 4, 6]
UNSHIFT([2, 4, 6], 4, true) // returns [2, 4, 6] (4 already exists)
UNSHIFT([2, 4, 6], 1, true) // returns [1, 2, 4, 6] (1 is new)
Parameters
- $anyArray : mixed
-
Array expression to prepend value to.
- $value : mixed
-
Value to prepend to the array.
- $unique : bool = false
-
When true, value is added only if not already present.
Tags
Return values
string —The formatted AQL expression.