PHPackages                             yii2mod/yii2-array-query - 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. yii2mod/yii2-array-query

ActiveYii2-extension

yii2mod/yii2-array-query
========================

Yii2 component that allows for searching/filtering the elements of an array.

1.4(6y ago)35167.1k↓19%115MITPHPPHP &gt;=7.0.0CI failing

Since Aug 29Pushed 6y ago6 watchersCompare

[ Source](https://github.com/yii2mod/yii2-array-query)[ Packagist](https://packagist.org/packages/yii2mod/yii2-array-query)[ RSS](/packages/yii2mod-yii2-array-query/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (3)Versions (6)Used By (5)

 [ ![](https://avatars0.githubusercontent.com/u/993323) ](https://github.com/yiisoft)

Yii2 ArrayQuery Component
=========================

[](#yii2-arrayquery-component)

Allows searching/filtering of an array. This component is very useful when displaying array data in GridViews with an ArrayDataProvider.

[![Latest Stable Version](https://camo.githubusercontent.com/80593d3c05b2f0ec41a97a27f9b5a1a8fa07f38c7683fd3e5f9f83f061f35714/68747470733a2f2f706f7365722e707567782e6f72672f796969326d6f642f796969322d61727261792d71756572792f762f737461626c65)](https://packagist.org/packages/yii2mod/yii2-array-query)[![Total Downloads](https://camo.githubusercontent.com/8e3ab6815752e812d44e6ac4183b236754b3d3f673aa596083cc7d5c94662a11/68747470733a2f2f706f7365722e707567782e6f72672f796969326d6f642f796969322d61727261792d71756572792f646f776e6c6f616473)](https://packagist.org/packages/yii2mod/yii2-array-query)[![License](https://camo.githubusercontent.com/e4e49e4096f74a173331838d00ab6a2e3852f7687e13b5737c920150bc261586/68747470733a2f2f706f7365722e707567782e6f72672f796969326d6f642f796969322d61727261792d71756572792f6c6963656e7365)](https://packagist.org/packages/yii2mod/yii2-array-query)[![Build Status](https://camo.githubusercontent.com/4c9b45d5d7275e5e1910e4f11c68dd31884a6fcc8a9e494c3dade19e958be149/68747470733a2f2f7472617669732d63692e6f72672f796969326d6f642f796969322d61727261792d71756572792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/yii2mod/yii2-array-query)

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist yii2mod/yii2-array-query "*"

```

or add

```
"yii2mod/yii2-array-query": "*"

```

to the require section of your composer.json.

Querying Data
-------------

[](#querying-data)

You may execute complex query on the array data using \[\[\\yii2mod\\query\\ArrayQuery\]\] class. This class works similar to regular \[\[\\yii\\db\\Query\]\] and uses same syntax. For example:

```
$data = [
    [
        'id' => 1,
        'username' => 'admin',
        'email' => 'admin@example.com'
    ],
    [
        'id' => 2,
        'username' => 'test',
        'email' => 'test@example.com'
    ],
];

$query = new ArrayQuery();
$query->from($data);
$query->where(['username' => 'admin']);

$rows = $query->all();
```

Using with ArrayDataProvider
----------------------------

[](#using-with-arraydataprovider)

You may perform filtering using \[\[\\yii2mod\\query\\ArrayQuery\]\] class. For example:

```
