---
title: "Combinations"
description: "Generate subsets of a list with a minimum number of elements"
type: "docs"
category: "doc"
tags: []
authors: [Anonymous]
date: "2026-10-26"
last_update: "2026-10-26"
time_minutes: 1
draft: false
unlisted: false
url: "https://www.derafu.dev/docs/data/array/combinations"
---

# ArrayCombinations

`ArrayCombinations::subsets($array, $minLength = 1)` enumerates subsets of a zero-based consecutive list. Each result is itself a list.

```php
use Derafu\Array\ArrayCombinations;

ArrayCombinations::subsets([1, 2, 3]);
// [[1], [2], [1, 2], [3], [1, 3], [2, 3], [1, 2, 3]]

ArrayCombinations::subsets([1, 2, 3], 2);
// [[1, 2], [1, 3], [2, 3], [1, 2, 3]]

ArrayCombinations::subsets([1, 2], 0);
// [[], [1], [2], [1, 2]]
```

Selection is by position, preserving the input order within each subset. Equal values at different positions can therefore produce equal-looking subsets. The input is unchanged.

The algorithm examines `2^n` combinations. By default it excludes the empty subset, returning `2^n - 1` results; a minimum length of zero includes it. Use small lists: raising the minimum length filters results but does not avoid examining the combinations.



---
Last updated on 26/10/2026

