Oihana PHP Arango

removeValue.php

Table of Contents

Functions

removeValue()  : string
Remove all occurrences of a value from an array.

Functions

removeValue()

Remove all occurrences of a value from an array.

removeValue(string $anyArray, mixed $value[, int|string|null $limit = null ]) : string

This helper wraps the ArangoDB AQL function REMOVE_VALUE(anyArray, value, limit) which removes all occurrences of a specified value from an array. An optional limit can be specified to limit the number of removals.

Example AQL usage:

REMOVE_VALUE([1, 2, 3, 2, 4], 2)        // returns [1, 3, 4]
REMOVE_VALUE([1, 2, 3, 2, 4], 2, 1)     // returns [1, 3, 2, 4] (only first occurrence)
REMOVE_VALUE([1, 2, 3], 5)               // returns [1, 2, 3] (value not found)
Parameters
$anyArray : string

Array expression to remove value from.

$value : mixed

Value to remove from the array.

$limit : int|string|null = null

Optional limit for the number of removals. Non-numeric or non-positive values (and null) are ignored (no limit).

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

$expr = removeValue('doc.tags', 'deprecated');
// Produces: 'REMOVE_VALUE(doc.tags, "deprecated")'

$expr = removeValue('doc.tags', 'deprecated', 1);
// Produces: 'REMOVE_VALUE(doc.tags, "deprecated", 1)'
see
https://docs.arangodb.com/stable/aql/functions/array/#remove_value
removeValues()

For removing multiple values at once.

since
1.0.0
author

Marc Alcaraz

Return values
string

The formatted AQL expression.

On this page

Search results