Oihana PHP Arango

average.php

Table of Contents

Functions

average()  : string
Return the average (arithmetic mean) of the values in an array.

Functions

average()

Return the average (arithmetic mean) of the values in an array.

average(mixed $anyArray) : string

This helper wraps the ArangoDB AQL function AVERAGE(numArray) which calculates the arithmetic mean of all numeric values in the given array.

Example AQL usage:

AVERAGE([5, 2, 9, 2])         // returns 4.5
AVERAGE(doc.scores)           // returns average of scores array
AVERAGE([1, 2, 3, 4, 5])      // returns 3.0
Parameters
$anyArray : mixed

Array expression containing numeric values.

Tags
example
use function oihana\arango\db\functions\numerics\average;

$expr = average('[5, 2, 9, 2]');
// Produces: 'AVERAGE([5, 2, 9, 2])'
see
https://docs.arangodb.com/stable/aql/functions/numeric/#average
since
1.0.0
author

Marc Alcaraz

Return values
string

The formatted AQL expression.

On this page

Search results