reduce.php
Table of Contents
Functions
- reduce() : array<int|string, mixed>
- Reduces an array by removing values based on conditions or using compress/clean.
Functions
reduce()
Reduces an array by removing values based on conditions or using compress/clean.
reduce(array<int|string, mixed> $array[, bool|array{clone?: bool, conditions?: callable|array|string|null, depth?: int|null, excludes?: array|null, recursive?: bool, removeKeys?: array|null, throwable?: bool}|callable $reduce = true ]) : array<int|string, mixed>
This function provides a unified interface for array reduction with three modes:
true: Remove null values using compress()array: Forward options to compress()callable: Custom filter function
Parameters
- $array : array<int|string, mixed>
-
The input array.
-
$reduce
: bool|array{clone?: bool, conditions?: callable|array
|string|null, depth?: int|null, excludes?: array = true|null, recursive?: bool, removeKeys?: array |null, throwable?: bool}|callable -
Reduction mode:
true: compress with default optionsarray: compress with custom options (CompressOption)callable: fn($value, $key): bool
Tags
Return values
array<int|string, mixed> —The reduced array.