Computations

sum

Definition

Arr::sum(array ...$arrays): array

Description

Sum associative arrays by their keys into one array

Examples

$arrays = [
    [
        'a' => 1,
        'b' => -3.5,
        'c' => 0,
        3
    ],
    [
        2,
        'a' => 0,
        'c' => -5,
        'd' => PHP_INT_MAX,
    ],
    [
        -5,
        'b' => 3.5,
        'a' => -1,
        'c' => 5,
    ],
    [
        'd' => PHP_INT_MAX,
    ],
    [
        'd' => 2 * -PHP_INT_MAX,
    ]
];

Arr::sum(...$arrays) ->
[
    0,
    'a' => 0,
    'b' => 0,
    'c' => 0,
    'd' => 0,
]

Arr::sum([null, '', false], ['1', true, 'test']) -> [1, 1, 0]

diffObjects

Declaration

Description

Compute difference between two or more arrays of objects

Examples

intersectObjects

Definition

Description

Compute intersection between two or more arrays of objects

Examples

Last updated

Was this helpful?