Oihana PHP Arango

toArray.php

Table of Contents

Functions

toArray()  : string
Converts a value of any type into an array.

Functions

toArray()

Converts a value of any type into an array.

toArray(mixed $value) : string

This helper wraps the ArangoDB AQL function TO_ARRAY(), which casts the provided value to an array. If the value is already an array, it is returned as is; otherwise, it will be wrapped in a single-element array.

Example AQL usage:

TO_ARRAY(doc.tags)   // returns doc.tags as an array
TO_ARRAY("single")   // returns ["single"]
Parameters
$value : mixed

The AQL field or expression to convert to an array.

Tags
example
use function oihana\arango\db\functions\toArray;

$expr = toArray('doc.items');
// Produces: 'TO_ARRAY(doc.items)'
see
https://docs.arangodb.com/stable/aql/functions/type-check-and-cast/#to_array
since
1.0.0

author Marc Alcaraz

Return values
string

The formatted AQL expression (e.g., 'TO_ARRAY(doc.items)').

On this page

Search results