Oihana PHP Arango

shift.php

Table of Contents

Functions

shift()  : string
Remove the first element of an array.

Functions

shift()

Remove the first element of an array.

shift(mixed $anyArray) : string

This helper wraps the ArangoDB AQL function SHIFT(anyArray) which removes and returns the first element of an array, modifying the original array. If the array is empty, it returns null.

Example AQL usage:

SHIFT([1, 2, 3])            // returns 1, array becomes [2, 3]
SHIFT(doc.items)            // removes first item from doc.items
SHIFT([])                   // returns null
Parameters
$anyArray : mixed

Array expression to remove first element from.

Tags
example
use function oihana\arango\db\functions\arrays\shift;

$expr = shift('[1, 2, 3]');
// Produces: 'SHIFT([1, 2, 3])'
see
https://docs.arangodb.com/stable/aql/functions/array/#shift
unshift()

For adding elements to the beginning.

push()

For adding elements to the end.

since
1.0.0
author

Marc Alcaraz

Return values
string

The formatted AQL expression.

On this page

Search results