reduce.php
Table of Contents
Functions
- reduce() : array<string|int, 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<string|int, mixed> $array[, bool|array<string|int, mixed>|callable $reduce = true ]) : array<string|int, 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<string|int, mixed>
-
The input array.
- $reduce : bool|array<string|int, mixed>|callable = true
-
Reduction mode:
true: compress with default optionsarray: compress with custom optionscallable: fn($value, $key): bool
Tags
Return values
array<string|int, mixed> —The reduced array.