partition.php
Table of Contents
Functions
-
partition()
: array{0: array
, 1: array } - Splits an array into two groups according to a predicate.
Functions
partition()
Splits an array into two groups according to a predicate.
partition(array<int|string, mixed> $items, callable $predicate) : array{0: array, 1: array}
The $predicate callback is invoked as fn( $value , $key ) for every entry.
Entries for which it returns a truthy value go into the first group, the others
into the second. Original keys are preserved in both groups.
Parameters
- $items : array<int|string, mixed>
-
The array to split.
- $predicate : callable
-
The test callback:
fn( $value , $key ): bool.
Tags
Return values
array{0: arrayA pair [ 0 => $passed , 1 => $failed ].