Oihana PHP Arango

push.php

Table of Contents

Functions

push()  : string
Append a value to the end of an array.

Functions

push()

Append a value to the end of an array.

push(mixed $anyArray, mixed $value[, bool $unique = false ]) : string

This helper wraps the ArangoDB AQL function PUSH(anyArray, value, unique) which adds a value to the end of an array. If unique is true, the value is only added if it's not already present in the array.

Example AQL usage:

PUSH([2, 4, 6], 8)          // returns [2, 4, 6, 8]
PUSH([2, 4, 6], 4)          // returns [2, 4, 6, 4]
PUSH([2, 4, 6], 4, true)    // returns [2, 4, 6] (4 already exists)
PUSH([2, 4, 6], 8, true)    // returns [2, 4, 6, 8] (8 is new)
Parameters
$anyArray : mixed

Array expression to append value to.

$value : mixed

Value to append to the array.

$unique : bool = false

When true, value is added only if not already present.

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

$expr = push('[2,4,6,8]', 4);
// Produces: 'PUSH([2,4,6,8],4)'

$expr = push('[2,4,6,8]', 4, true);
// Produces: 'PUSH([2,4,6,8],4,true)'
see
https://docs.arangodb.com/stable/aql/functions/array/#push
unshift()

For prepending values to the beginning.

append()

For appending multiple values.

since
1.0.0
author

Marc Alcaraz

Return values
string

The formatted AQL expression.

On this page

Search results