PHPackages                             francerz/php-power-data - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. francerz/php-power-data

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

francerz/php-power-data
=======================

PHP data structures for complex data handling

v0.1.39(8mo ago)02.1k9PHPCI failing

Since Oct 5Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/francerz/php-power-data)[ Packagist](https://packagist.org/packages/francerz/php-power-data)[ RSS](/packages/francerz-php-power-data/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (6)DependenciesVersions (41)Used By (9)

PHP Power Data
==============

[](#php-power-data)

Installation
------------

[](#installation)

This package can be installed with composer using following command.

```
composer require francerz/php-power-data

```

Using `Index` class
-------------------

[](#using-index-class)

```
use Francerz\PowerData\Index;

$index = new Index($data, ['column1', 'column2']);

$col1Values = $index->getColumnValues('column1');
$col2Values = $index->getColumnValues('column2');

foreach ($col1Values as $c1) {
    foreach ($col2Values as $c2) {
        // Retrieves all items that matches $c1 and $c2.
        $items = $index[['column1' => $c1, 'column2' => $c2]];

        $numItems = $index->xCount(['column1' => $c1, 'column2' => $c2]);
        $sumCol3 = $index->sum('column3', ['column1' => $c1, 'column2' => $c2]);
        $first = $index->first(['column1' => $c1, 'column2' => $c2]);
        $last = $index->last(['column1' => $c1, 'column2' => $c2]);
    }
    // Retrieves all items that matches $c1
    $items = $index[['column1' => $c1]];
}
```

### Method `groupBy($columns)`

[](#method-groupbycolumns)

The `groupBy` method allows you to group records from an indexed dataset based on one or more column values. The grouping is performed incrementally, meaning that the method applies filters progressively on the existing index to avoid unnecesary memory and processing overhead. This ensures that the performance remains efficient, even with large datasets.

#### Parameters:

[](#parameters)

- `$columns` (string|array): The name of a single column (string) or an array of column names (array) by which the data should be grouped. The method will return a nested grouping if multiple columns are provided.

#### Returns:

[](#returns)

- **array**: Returns a nested associative array, where each key corresponds to the unique values in the specified columns. The innermost arrays contain the records that match teh specific grouping of column values.

#### How it works:

[](#how-it-works)

The methods does not create a new index fore each group. Instead, progressively filters the data of each column's unique values, grouping the results step by step. This approach reduces memory consumption and processing time by avoiding redundant operations on the dataset.

#### Example Usage:

[](#example-usage)

```
$index = new Index($data, ['country', 'city']);

// Group by a single column
$groupedByCity = $index->groupBy('city');

// Group by multiple columns
$groupedByCountryAndCity = $index->groupBy(['country', 'city']);

print_r($groupedByCity);
```

Aggregations
------------

[](#aggregations)

```
Aggregations::concat(array $values, $separator = '')
Aggregations::count(array $values, bool $ignoreNulls = false)
Aggregations::findPercentile(array $values, float $value, int $flags = self::PERCENTILE_FLAGS_MIDDLE)
Aggregations::first(array $values)
Aggregations::frequencies(array $values)
Aggregations::last(array $values)
Aggregations::max(array $values)
Aggregations::mean(array $values, bool $ignoreNulls = false)
Aggregations::median(array $values)
Aggregations::min(array $values)
Aggregations::mode(array $values, bool $strict = false)
Aggregations::percentile(array $values, float $percentile, int $flags = self::PERCENTILE_FLAGS_MIDDLE)
Aggregations::product(array $values, bool $ignoreEmpty = false)
Aggregations::sum(array $values)
```

Arrays
------

[](#arrays)

```
Arrays::hasNumericKeys(array $array)
Arrays::hasStringKeys(array $array)
Arrays::findKeys(array $array, string $pattern)
Arrays::remove(array &$array, $value)
Arrays::filter($array, $callback = null, $flag = 0)
Arrays::intersect(array $array1, array $array2, ...$_)
```

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance58

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~46 days

Recently: every ~168 days

Total

40

Last Release

265d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/630263d156ec44e1d55c3d237fe08354442d0cbe7b257032997d0a649baf1854?d=identicon)[francerz](/maintainers/francerz)

---

Top Contributors

[![francerz](https://avatars.githubusercontent.com/u/10836837?v=4)](https://github.com/francerz "francerz (91 commits)")

### Embed Badge

![Health badge](/badges/francerz-php-power-data/health.svg)

```
[![Health](https://phpackages.com/badges/francerz-php-power-data/health.svg)](https://phpackages.com/packages/francerz-php-power-data)
```

###  Alternatives

[cloudcake/nova-snowball

A beautiful contrast of dark blue and white packaged for Laravel Nova as a theme.

3844.6k](/packages/cloudcake-nova-snowball)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
