Distinct

This function removes duplicate values from an array.

Syntax

array distinct(array $input)

Parameters

$input: The array to make distinct.

Example

{
    "input": [
        { "name": "Bob", "id": 0 },
        { "name": "Ann", "id": 0 },
        { "name": "Joe", "id": 1 },
        { "name": "Joe", "id": 1 }
    ]
}
{
    DistinctArray: distinct(input)
}
{
    "DistinctArray": [
        { "name": "Bob", "id": 0 },
        { "name": "Ann", "id": 0 },
        { "name": "Joe", "id": 1 }
    ]
}

The function evaluates the properties of the objects. And as input[2] and input[3] is identical, the duplicate is removed.