Skip to content

New partition() collection method#175

Merged
techmahedy merged 2 commits intodoppar:3.xfrom
techmahedy:techmahedy-3.x
Jan 22, 2026
Merged

New partition() collection method#175
techmahedy merged 2 commits intodoppar:3.xfrom
techmahedy:techmahedy-3.x

Conversation

@techmahedy
Copy link
Member

Split the collection into two groups based on a condition. Returns [passed, failed]

Example usages:

// Separate active and inactive users
[$active, $inactive] = $users->partition(fn($user) => $user['active']);

// Split passing and failing grades
[$passed, $failed] = $grades->partition(fn($grade) => $grade >= 60);

// Separate in-stock and out-of-stock items
[$inStock, $outOfStock] = $products->partition(
    fn($p) => $p['quantity'] > 0
);

@techmahedy techmahedy merged commit 6a26f33 into doppar:3.x Jan 22, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant