Oihana PHP Arango

last.php

Table of Contents

Functions

last()  : string
Get the last element of an array.

Functions

last()

Get the last element of an array.

last(mixed $anyArray) : string

This helper wraps the ArangoDB AQL function LAST(anyArray) which returns the last element of the given array. If the array is empty, it returns null.

Example AQL usage:

LAST([1, 2, 3])             // returns 3
LAST(doc.items)             // returns last item from doc.items
LAST([])                    // returns null
Parameters
$anyArray : mixed

Array expression to get the last element from.

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

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

For getting the first element.

since
1.0.0
author

Marc Alcaraz

Return values
string

The formatted AQL expression.

On this page

Search results