PHPackages                             asimlqt/arrayquery - 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. asimlqt/arrayquery

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

asimlqt/arrayquery
==================

Array query

392PHP

Since May 29Pushed 12y ago3 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

ArrayQuery
==========

[](#arrayquery)

ArrayQuery is a library to query, group and sort data stored in a nested php array format.

### Example

[](#example)

```
use Asimlqt\ArrayQuery\Input\ArrayOfArrays;
use Asimlqt\ArrayQuery\Query;

$data = array(
    array(
        'continent' => 'Europe',
        'country' => 'England',
        'city' => 'London',
        'population' => '8000000'
    ),
    array(
        'continent' => 'Europe',
        'country' => 'France',
        'city' => 'Paris',
        'population' => '2200000'
    ),
    array(
        'continent' => 'Asia',
        'country' => 'Japan',
        'city' => 'Tokyo',
        'population' => '13200000'
    ),
);

$source = new ArrayOfArrays($data);
$query = new Query($source);
$query->where(function($row) { return $row['population'] > 5000000; });
print_r($query->getResult());

```

### API

[](#api)

#### select($columns)

[](#selectcolumns)

Select is similar to a select in an sql query, It only keeps the columns which are passed to the method and discards all others. This sohuld generally be called after queryingfor the required data, just before calling getResult(). Once select has been called, you can not filter or query on the rows which have been removed by the select as they no longer exist.

```
$query->select(array('city', 'population'));
```

#### filter($column, array $values)

[](#filtercolumn-array-values)

Filter removes columns which don't have one of the specified values. It is similar to a "WHERE IN" clause in mysql.

```
$query->filter('city', array('London', 'Paris'));
```

#### where($closure)

[](#whereclosure)

The where function gives the freedom of filtering data in any way the user likes. The closure accepts the current row and must return true or false. If the function returns boolean true then the row will be kept, any other value will cause the row to be removed.

```
$query->where(function($row) { return $row['population'] > 5000000; });
```

#### groupBy($columns, $closure)

[](#groupbycolumns-closure)

Allows grouping of data so that there will be only one row for each unique set of the specified column values.

```
$query->groupBy(array('continent', 'country'));
```

You can optionally specify a closure as the second argument. If a closure is specified then it will be called each time a duplicate row is found for the specified columns. The return value must be a row. e.g.

```
$query->groupBy(array('continent', 'country'), function($oldRow, $newRow) {
	$oldRow['population'] += $newRow['population'];
	return $oldRow;
});
```

#### orderBy(array $order)

[](#orderbyarray-order)

Allows ordering of the data by one or more columns. The key of the array is the column name and the value is either SORT\_ASC or SORT\_DESC.

```
$query->orderBy(array('continent' => SORT_ASC, 'population' => SORT_DESC));
```

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8d1ba605a0d5efec9649a10ac22f37d0c140e8ee928daac34686e987719bee17?d=identicon)[Asim](/maintainers/Asim)

---

Top Contributors

[![asimlqt](https://avatars.githubusercontent.com/u/1963846?v=4)](https://github.com/asimlqt "asimlqt (11 commits)")

### Embed Badge

![Health badge](/badges/asimlqt-arrayquery/health.svg)

```
[![Health](https://phpackages.com/badges/asimlqt-arrayquery/health.svg)](https://phpackages.com/packages/asimlqt-arrayquery)
```

###  Alternatives

[magepow/stickycart

Magepow Sticky Cart

1614.7k](/packages/magepow-stickycart)

PHPackages © 2026

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