PHPackages                             parfumix/arrayy - 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. parfumix/arrayy

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

parfumix/arrayy
===============

Array manipulation library for PHP, called Arrayy!

3.7.0(8y ago)046MITPHPPHP &gt;=5.3.0

Since Jan 26Pushed 8y ago2 watchersCompare

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

READMEChangelogDependencies (3)Versions (39)Used By (0)

[![Stories in Ready](https://camo.githubusercontent.com/b9aa03675404b3176f6f5199af93f6407f5747ed01b3b8f8fccbbdeffb9197c4/68747470733a2f2f62616467652e776166666c652e696f2f766f6b752f4172726179792e706e673f6c6162656c3d7265616479267469746c653d5265616479)](https://waffle.io/voku/Arrayy)[![Build Status](https://camo.githubusercontent.com/18f2de43dc83b61d07976698a595c635937ca3c3908b112c620669309a322dbc/68747470733a2f2f6170692e7472617669732d63692e6f72672f766f6b752f4172726179792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/voku/Arrayy)[![Coverage Status](https://camo.githubusercontent.com/dfaa016ed49b620d098b74350eac1496a9b3582e16a5591387a828e53e9cc842/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f766f6b752f4172726179792f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/voku/Arrayy?branch=master)[![codecov.io](https://camo.githubusercontent.com/ab617ee4985eafac20d7be1b5ea30603c348425ee26cef0b2e290297d9b0be69/68747470733a2f2f636f6465636f762e696f2f6769746875622f766f6b752f4172726179792f636f7665726167652e7376673f6272616e63683d6d6173746572)](https://codecov.io/github/voku/Arrayy?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/1b1910e62ee47a044a817553dee3060751074e72ef42c5271996366ac69ca6f2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f766f6b752f4172726179792f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/voku/Arrayy/?branch=master)[![Codacy Badge](https://camo.githubusercontent.com/882f771442af0d3e9a433ff3224ef29d82d725e8154d1fafa875d29275a1b626/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f67726164652f6238633463383861303633353435643738376532613466316635646664663233)](https://www.codacy.com/app/voku/Arrayy)[![SensioLabsInsight](https://camo.githubusercontent.com/42896e316c20a04e378b0562407650e10396d9dd3d9888dc1f776799b9d6ac89/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f31633963376264612d313861622d343664612d613966342d6639613464623164633435632f6d696e692e706e67)](https://insight.sensiolabs.com/projects/1c9c7bda-18ab-46da-a9f4-f9a4db1dc45c)[![Latest Stable Version](https://camo.githubusercontent.com/852cf36f6238c7826cffdaf42e34b663fbd32670244711ed8a92146480d38483/68747470733a2f2f706f7365722e707567782e6f72672f766f6b752f6172726179792f762f737461626c65)](https://packagist.org/packages/voku/arrayy)[![Total Downloads](https://camo.githubusercontent.com/46d37ea0c37ee6b43678aebea34170d083f4d14c87971ccdeca15ffbac4f962d/68747470733a2f2f706f7365722e707567782e6f72672f766f6b752f6172726179792f646f776e6c6f616473)](https://packagist.org/packages/voku/arrayy)[![Latest Unstable Version](https://camo.githubusercontent.com/ecbf589bde1b441091a8ca8767c0b4d18562cbee7f93f5ba2938927bbfd5ed39/68747470733a2f2f706f7365722e707567782e6f72672f766f6b752f6172726179792f762f756e737461626c65)](https://packagist.org/packages/voku/arrayy)[![PHP 7 ready](https://camo.githubusercontent.com/4dc70c2b3afa075437c3c0bc4107070e71d2b9a6831f67e105c57ea87a3cf8a4/687474703a2f2f7068703772656164792e74696d6573706c696e7465722e63682f766f6b752f4172726179792f62616467652e737667)](https://travis-ci.org/voku/Arrayy)[![License](https://camo.githubusercontent.com/80150af186768652215c68d4d556e93816e9f575862abfe8fb9432f6c2bf8108/68747470733a2f2f706f7365722e707567782e6f72672f766f6b752f6172726179792f6c6963656e7365)](https://packagist.org/packages/voku/arrayy)

[documentation via gitbooks.io](https://voku.gitbooks.io/arrayy/content/)

A PHP array manipulation library. Compatible with PHP 5.3+, PHP 7, and HHVM.

```
Arrayy::create(['Array', 'Array'])->unique()->append('y')->implode() // Arrayy
```

- [Instance methods](#instance-methods)
    - ["set an array value"](#set-an-array-value)
    - ["set an array value via dot-notation"](#setmixed-key-mixed-value--arrayy-immutable)
    - ["get an array value"](#get-an-array-value)
    - ["get an array value via dot-notation"](#getstring-key-null-default-null-array--mixed)
    - ["get the array"](#get-the-array)
    - ["delete an array value"](#delete-an-array-value)
    - ["check if an array value is-set"](#check-if-an-array-value-is-set)
    - ["simple loop with an Arrayy-object"](#simple-loop-with-an-arrayy-object)
    - [append](#appendmixed-value--arrayy-mutable)
    - [prepend](#prependmixed-value--arrayy-mutable)
    - [at](#atclosure-closure--arrayy-immutable)
    - [average](#averageint-decimals--intdouble)
    - [chunk](#chunkint-size-bool-preservekeys--arrayy-immutable)
    - [clean](#clean--arrayy-immutable)
    - [clear](#clear--arrayy-mutable)
    - [customSortKeys](#customsortkeysfunction--arrayy-mutable)
    - [customSortValues](#customsortvaluesfunction--arrayy-mutable)
    - [contains](#containsmixed-value--boolean)
    - [containsKey](#containskeymixed-key--boolean)
    - [diff](#diffarray-array--arrayy-immutable)
    - [diffReverse](#diffreversearray-array--arrayy-immutable)
    - [diffRecursive](##diffrecursivearray-array-nullarray-helpervariableforrecursion--arrayy-immutable)
    - [each](#eachclosure-closure--arrayy-immutable)
    - [exists](#existsclosure-closure--boolean)
    - [filter](#filterclosurenull-closure--arrayy-immutable)
    - [filterBy](#filterby--arrayy-immutable)
    - [find](#findclosure-closure--mixed)
    - [first](#first--mixed)
    - [firstsMutable](#firstsmutablenullint-take--arrayy-mutable)
    - [firstsImmutable](#firstsimmutablenullint-take--arrayy-immutable)
    - [flip](#flip--arrayy-immutable)
    - [getColumn](#getcolumnmixed-columnkey-mixed-indexkey--arrayy)
    - [getIterator](#getiterator)
    - [implode](#implodestring-with--string)
    - [initial](#initialint-to--arrayy-immutable)
    - [intersection](#intersectionarray-search--arrayy-immutable)
    - [intersects](#intersectsarray-search--boolean)
    - [isAssoc](#isassoc--boolean)
    - [isMultiArray](#ismultiarray--boolean)
    - [keys](#keys--arrayy-immutable)
    - [last](#last--mixed)
    - [lastsImmutable](#lastsimmutablenullint-take--arrayy-immutable)
    - [lastsMutable](#lastsmutablenullint-take--arrayy-mutable)
    - [length](#length--int)
    - [max](#max--mixed)
    - [matches](#matchesclosure-closure--boolean)
    - [matchesAny](#matchesanyclosure-closure--boolean)
    - [mergeAppendKeepIndex](#mergeappendkeepindexarray-array--arrayy-immutable)
    - [mergePrependKeepIndex](#mergeprependkeepindexarray-array--arrayy-immutable)
    - [mergeAppendNewIndex](#mergeappendnewindexarray-array--arrayy-immutable)
    - [mergePrependNewIndex](#mergeprependnewindexarray-array--arrayy-immutable)
    - [min](#min--mixed)
    - [randomKey](#randomkey--mixed)
    - [randomKeys](#randomkeys--arrayy-immutable)
    - [randomValue](#randomvalue--mixed)
    - [randomValues](#randomvalues--arrayy-immutable)
    - [randomImmutable](#randomimmutableintnull-take--arrayy-immutable)
    - [randomMutable](#randommutableintnull-take--arrayy-mutable)
    - [randomWeighted](#randomweightedarray-array-intnull-take--arrayy-immutable)
    - [reduce](#reducecallable-predicate-array-init--arrayy-immutable)
    - [reindex](#reindex--arrayy-mutable)
    - [reject](#rejectclosure-closure--arrayy-immutable)
    - [remove](#removemixed-key--immutable)
    - [removeFirst](#removefirst--arrayy-immutable)
    - [removeLast](#removelast--arrayy-immutable)
    - [removeValue](#removevaluemixed-value--arrayy-immutable)
    - [replace](#replacearray-keys--arrayy-immutable)
    - [replaceAllKeys](#replaceallkeysarray-keys--arrayy-immutable)
    - [replaceAllValues](#replaceallvaluesarray-array--arrayy-immutable)
    - [replaceKeys](#replacekeysarray-keys--arrayy-immutable)
    - [replaceOneValue](#replaceonevaluemixed-search-mixed-replacement--arrayy-immutable)
    - [replaceValues](#replacevaluesstring-search-string-replacement--arrayy-immutable)
    - [rest](#restint-from--arrayy-immutable)
    - [reverse](#reverse--arrayy-mutable)
    - [searchIndex](#searchindexmixed-value--mixed)
    - [searchValue](#searchvaluemixed-index--arrayy-immutable)
    - [sort](#sortstringintsort_asc-direction-intsort_regular-strategy-boolfalse-keepkeys--arrayy-mutable)
    - [sorter](#sorternullcallable-sorter-stringintsort_asc-direction-intsort_regular-strategy--arrayy-immutable)
    - [sortKeys](#sortkeysstringintsort_asc-direction--arrayy-mutable)
    - [sortValueNewIndex](#sortvaluenewindexstringintsort_asc-direction-intsort_regular-strategy--arrayy-immutable)
    - [sortValueKeepIndex](#sortvaluekeepindexstringintsort_asc-direction-intsort_regular-strategy--arrayy-immutable)
    - [split](#splitint2-numberofpieces-boolfalse-keepkeys--arrayy-immutable)
    - [shuffle](#shuffle--arrayy-immutable)
    - [toJson](#tojson--string)
    - [unique](#unique--arrayy-mutable)
    - [values](#values--arrayy-immutable)
    - [walk](#walk--arrayy-mutable)
- [Tests](#tests)
- [License](#license)

Installation via "composer require"
-----------------------------------

[](#installation-via-composer-require)

```
composer require voku/arrayy
```

Installation via composer (manually)
------------------------------------

[](#installation-via-composer-manually)

If you're using Composer to manage dependencies, you can include the following in your composer.json file:

```
"require": {
    "voku/arrayy": "3.*"
}
```

Then, after running `composer update` or `php composer.phar update`, you can load the class using Composer's autoloading:

```
require 'vendor/autoload.php';
```

And in either case, I'd suggest using an alias.

```
use Arrayy\Arrayy as A;
```

Multidimensional ArrayAccess
----------------------------

[](#multidimensional-arrayaccess)

You can access / change the array via Object, Array or with "Arrayy"-syntax.

### Access via "Arrayy"-syntax: (dot-notation)

[](#access-via-arrayy-syntax-dot-notation)

\-- **Recommended** --

```
$arrayy = new A(['Lars' => ['lastname' => 'Moelleken']]);

$arrayy->get('Lars'); // ['lastname' => 'Moelleken']
$arrayy->get('Lars.lastname'); // 'Moelleken'
```

### Access via "array"-syntax:

[](#access-via-array-syntax)

```
$arrayy = new A(['Lars' => ['lastname' => 'Moelleken']]);

$arrayy['Lars'];             // ['lastname' => 'Moelleken']
$arrayy['Lars']['lastname']; // 'Moelleken'
```

### Access via "object"-syntax:

[](#access-via-object-syntax)

```
$arrayy = new A(['Lars' => ['lastname' => 'Moelleken']]);

$arrayy->Lars; // Arrayy['lastname' => 'Moelleken']
$arrayy->Lars->lastname; // 'Moelleken'
```

### Set values via "Arrayy"-syntax: (dot-notation)

[](#set-values-via-arrayy-syntax-dot-notation)

\-- **Recommended** --

```
$arrayy = new A(['Lars' => ['lastname' => 'Mueller']]);

$arrayy->set('Lars.lastname', 'Moelleken');
$arrayy->get('Lars.lastname'); // 'Moelleken'
```

### Set values via "array"-syntax:

[](#set-values-via-array-syntax)

```
$arrayy = new A(['Lars' => ['lastname' => 'Moelleken']]);

$arrayy['Lars'] = array('lastname' => 'Müller');
$arrayy['Lars']['lastname]; // 'Müller'
```

### Set values via "object"-syntax:

[](#set-values-via-object-syntax)

```
$arrayy = new A(['Lars' => ['lastname' => 'Moelleken']]);

$arrayy->Lars = array('lastname' => 'Müller');
$arrayy->Lars->lastname; // 'Müller'
```

OO and Chaining
---------------

[](#oo-and-chaining)

The library offers OO method chaining, as seen below:

```
echo a(['fòô', 'bàř', 'bàř'])->unique()->reverse()->implode(','); // 'bàř,fòô'
```

Implemented Interfaces
----------------------

[](#implemented-interfaces)

`Arrayy\Arrayy` implements the `IteratorAggregate` interface, meaning that `foreach` can be used with an instance of the class:

```
$arrayy = a(['fòôbàř', 'foo']);
foreach ($arrayy as $value) {
    echo $value;
}
// 'fòôbàř'
// 'foo'
```

It implements the `Countable` interface, enabling the use of `count()` to retrieve the number of elements in the array:

```
$arrayy = a(['fòô', 'foo']);
count($arrayy);  // 2
```

PHP 5.6 Creation
----------------

[](#php-56-creation)

As of PHP 5.6, [`use function`](https://wiki.php.net/rfc/use_function) is available for importing functions. Arrayy exposes a namespaced function, `Arrayy\create`, which emits the same behaviour as `Arrayy\Arrayy::create()`. If running PHP 5.6, or another runtime that supports the `use function` syntax, you can take advantage of an even simpler API as seen below:

```
use function Arrayy\create as a;

// Instead of: A::create(['fòô', 'bàř'])->reverse()->implode();
a(['fòô', 'bàř'])->reverse()->implode(','); // 'bàř,fòô'
```

StaticArrayy
------------

[](#staticarrayy)

All methods listed under "Instance methods" are available as part of a static wrapper.

```
use Arrayy\StaticArrayy as A;

// Translates to Arrayy::create(['fòô', 'bàř'])->reverse();
// Returns an Arrayy object with the array
A::reverse(['fòô', 'bàř']);
```

Class methods
-------------

[](#class-methods)

##### use a "default object"

[](#use-a-default-object)

Creates an Arrayy object.

```
$arrayy = new Arrayy(array('fòô', 'bàř')); // Arrayy['fòô', 'bàř']
```

##### create(array $array) : Arrayy (Immutable)

[](#createarray-array--arrayy-immutable)

Creates an Arrayy object, via static "create()"-method

```
$arrayy = A::create(array('fòô', 'bàř')); // Arrayy['fòô', 'bàř']
```

##### createByReference(array &amp;$array) : Arrayy (Mutable)

[](#createbyreferencearray-array--arrayy-mutable)

WARNING: Creates an Arrayy object by reference.

```
$array = array('fòô', 'bàř');
$arrayy = A::createByReference($array); // Arrayy['fòô', 'bàř']
```

##### createFromJson(string $json) : Arrayy (Immutable)

[](#createfromjsonstring-json--arrayy-immutable)

Create an new Arrayy object via JSON.

```
$str = '{"firstName":"John", "lastName":"Doe"}';
$arrayy = A::createFromJson($str); // Arrayy['firstName' => 'John', 'lastName' => 'Doe']
```

##### createFromObject(ArrayAccess $object) : Arrayy (Immutable)

[](#createfromobjectarrayaccess-object--arrayy-immutable)

Create an new instance filled with values from an object that have implemented ArrayAccess.

```
$object = A::create(1, 'foo');
$arrayy = A::createFromObject($object); // Arrayy[1, 'foo']
```

##### createFromObjectVars(\\object $object) : Arrayy (Immutable)

[](#createfromobjectvarsobject-object--arrayy-immutable)

Create an new instance filled with values from an object.

```
$object = new stdClass();
$object->x = 42;
$arrayy = A::createFromObjectVars($object); // Arrayy['x' => 42]
```

##### createWithRange() : Arrayy (Immutable)

[](#createwithrange--arrayy-immutable)

Create an new instance containing a range of elements.

```
$arrayy = A::createWithRange(2, 4); // Arrayy[2, 3, 4]
```

##### createFromString(string $str) : Arrayy (Immutable)

[](#createfromstringstring-str--arrayy-immutable)

Create an new Arrayy object via string.

```
$arrayy = A::createFromString(' foo, bar '); // Arrayy['foo', 'bar']
```

Instance Methods
----------------

[](#instance-methods)

Arrayy: All examples below make use of PHP 5.6 function importing, and PHP 5.4 short array syntax. For further details, see the documentation for the create method above, as well as the notes on PHP 5.6 creation.

##### "set an array value"

[](#set-an-array-value)

```
$arrayy = a(['fòô' => 'bàř']);
$arrayy['foo'] = 'bar';
var_dump($arrayy); // Arrayy['fòô' => 'bàř', 'foo' => 'bar']
```

##### "get an array value"

[](#get-an-array-value)

```
$arrayy = a(['fòô' => 'bàř']);
var_dump($arrayy['fòô']); // 'bàř'
```

##### "get the array"

[](#get-the-array)

```
$arrayy = a(['fòô' => 'bàř']);
var_dump($arrayy->getArray()); // ['fòô' => 'bàř']
```

##### "delete an array value"

[](#delete-an-array-value)

```
$arrayy = a(['fòô' => 'bàř', 'lall']);
unset($arrayy['fòô']);
var_dump($arrayy); // Arrayy[0 => 'lall']
```

##### "check if an array value is-set"

[](#check-if-an-array-value-is-set)

```
$arrayy = a(['fòô' => 'bàř']);
isset($arrayy['fòô']); // true
```

##### "simple loop with an Arrayy-object"

[](#simple-loop-with-an-arrayy-object)

```
$arrayy = a(['fòô' => 'bàř'];
foreach ($arrayy) as $key => $value) {
  echo $key . ' | ' . $value; // fòô | bàř
}
```

##### append(mixed $value) : Arrayy (Mutable)

[](#appendmixed-value--arrayy-mutable)

Append a value to the current array.

alias: "Arrayy-&gt;add()"

```
a(['fòô' => 'bàř'])->append('foo'); // Arrayy['fòô' => 'bàř', 0 => 'foo']
```

##### prepend(mixed $value) : Arrayy (Mutable)

[](#prependmixed-value--arrayy-mutable)

Prepend a value to the current array.

```
a(['fòô' => 'bàř'])->prepend('foo'); // Arrayy[0 => 'foo', 'fòô' => 'bàř']
```

##### at(Closure $closure) : Arrayy (Immutable)

[](#atclosure-closure--arrayy-immutable)

Iterate over the current array and execute a callback for each loop.

```
$result = A::create();
$closure = function ($value, $key) use ($result) {
  $result[$key] = ':' . $value . ':';
};
a(['foo', 'bar' => 'bis'])->at($closure); // Arrayy[':foo:', 'bar' => ':bis:']
```

##### average(int $decimals) : int|double

[](#averageint-decimals--intdouble)

Returns the average value of the current array.

```
a([-9, -8, -7, 1.32])->average(2); // -5.67
```

##### chunk(int $size, bool $preserveKeys) : Arrayy (Immutable)

[](#chunkint-size-bool-preservekeys--arrayy-immutable)

Create a chunked version of the current array.

```
a([-9, -8, -7, 1.32])->chunk(2); // Arrayy[[-9, -8], [-7, 1.32]]
```

##### clean() : Arrayy (Immutable)

[](#clean--arrayy-immutable)

Clean all falsy values from the current array.

```
a([-8 => -9, 1, 2 => false])->clean(); // Arrayy[-8 => -9, 1]
```

##### clear() : Arrayy (Mutable)

[](#clear--arrayy-mutable)

WARNING!!! -&gt; Clear the current array.

```
a([-8 => -9, 1, 2 => false])->clear(); // Arrayy[]
```

##### customSortKeys($function) : Arrayy (Mutable)

[](#customsortkeysfunction--arrayy-mutable)

Custom sort by index via "uksort".

```
$callable = function ($a, $b) {
  if ($a == $b) {
    return 0;
  }
  return ($a > $b) ? 1 : -1;
};
$arrayy = a(['three' => 3, 'one' => 1, 'two' => 2]);
$resultArrayy = $arrayy->customSortKeys($callable); // Arrayy['one' => 1, 'three' => 3, 'two' => 2]
```

##### customSortValues($function) : Arrayy (Mutable)

[](#customsortvaluesfunction--arrayy-mutable)

Custom sort by value via "usort".

```
$callable = function ($a, $b) {
  if ($a == $b) {
    return 0;
  }
  return ($a > $b) ? 1 : -1;
};
$arrayy = a(['three' => 3, 'one' => 1, 'two' => 2]);
$resultArrayy = $arrayy->customSortValues($callable); // Arrayy['one' => 1, 'two' => 2, 'three' => 3]
```

##### contains(string|int|float $value) : boolean

[](#containsstringintfloat-value--boolean)

Check if an item is in the current array.

alias: "Arrayy-&gt;containsValue()"

```
a([1, true])->contains(true); // true
```

##### containsValues(array $values) : boolean

[](#containsvaluesarray-values--boolean)

Check if all given needles are present in the array.

```
a([1, true])->containsValues(array(1, true)); // true
```

##### containsKey(string|int|float $key) : boolean

[](#containskeystringintfloat-key--boolean)

Check if the given key/index exists in the array.

```
a([1 => true])->containsKey(1); // true
```

##### containsKeys(array $key) : boolean

[](#containskeysarray-key--boolean)

Check if all given needles are present in the array as key/index.

```
a([1 => true])->containsKeys(array(1 => 0)); // true
```

##### containsCaseInsensitive(string $value) : boolean

[](#containscaseinsensitivestring-value--boolean)

Check if an (case-insensitive) string is in the current array.

```
a(['E', 'é'])->containsCaseInsensitive('É'); // true
```

##### diff(array $array) : Arrayy (Immutable)

[](#diffarray-array--arrayy-immutable)

Return values that are only in the current array.

```
a([1 => 1, 2 => 2])->diff([1 => 1]); // Arrayy[2 => 2]
```

##### diffReverse(array $array) : Arrayy (Immutable)

[](#diffreversearray-array--arrayy-immutable)

Return values that are only in the new $array.

```
a([1 => 1])->diffReverse([1 => 1, 2 => 2]); // Arrayy[2 => 2]
```

##### diffRecursive(array $array, null|array $helperVariableForRecursion) : Arrayy (Immutable)

[](#diffrecursivearray-array-nullarray-helpervariableforrecursion--arrayy-immutable)

Return values that are only in the current multi-dimensional array.

```
a([1 => [1 => 1], 2 => [2 => 2]])->diffRecursive([1 => [1 => 1]]); // Arrayy[2 => [2 => 2]]
```

##### divide() : Arrayy (Immutable)

[](#divide--arrayy-immutable)

Divide an array into two arrays. One with keys and the other with values.

```
a(['a' => 1, 'b' => ''])->divide(); // Arrayy[Arrayy['a', 'b'], Arrayy[1, '']]
```

##### each(Closure $closure) : Arrayy (Immutable)

[](#eachclosure-closure--arrayy-immutable)

Iterate over the current array and modify the array's value.

```
$result = A::create();
$closure = function ($value) {
  return ':' . $value . ':';
};
a(['foo', 'bar' => 'bis'])->each($closure); // Arrayy[':foo:', 'bar' => ':bis:']
```

##### exists(Closure $closure) : boolean

[](#existsclosure-closure--boolean)

```
$callable = function ($value, $key) {
  return 2 === $key and 'two' === $value;
};
a(['foo', 2 => 'two'])->exists($callable); // true
```

##### filter(Closure|null $closure) : Arrayy (Immutable)

[](#filterclosurenull-closure--arrayy-immutable)

Find all items in an array that pass the truth test.

```
$closure = function ($value) {
  return $value % 2 !== 0;
}
a([1, 2, 3, 4])->filter($closure); // Arrayy[0 => 1, 2 => 3]
```

##### filterBy() : Arrayy (Immutable)

[](#filterby--arrayy-immutable)

Filters an array of objects (or a numeric array of associative arrays) based on the value of a particular property within that.

```
$array = [
  0 => ['id' => 123, 'name' => 'foo', 'group' => 'primary', 'value' => 123456, 'when' => '2014-01-01'],
  1 => ['id' => 456, 'name' => 'bar', 'group' => 'primary', 'value' => 1468, 'when' => '2014-07-15'],
};
a($array)->filterBy('name', 'foo'); // Arrayy[0 => ['id' => 123, 'name' => 'foo', 'group' => 'primary', 'value' => 123456, 'when' => '2014-01-01']]
```

##### find(Closure $closure) : mixed

[](#findclosure-closure--mixed)

Find the first item in an array that passes the truth test, otherwise return false.

```
$search = 'foo';
$closure = function ($value, $key) use ($search) {
  return $value === $search;
};
a(['foo', 'bar', 'lall'])->find($closure); // 'foo'
```

##### first() : mixed

[](#first--mixed)

Get the first value from the current array and return null if there wasn't a element.

```
a([2 => 'foo', 3 => 'bar', 4 => 'lall'])->first(); // 'foo'
```

##### firstsMutable(null|int $take) : Arrayy (Mutable)

[](#firstsmutablenullint-take--arrayy-mutable)

Get the first value(s) from the current array.

```
a([2 => 'foo', 3 => 'bar', 4 => 'lall'])->firsts(2); // Arrayy[0 => 'foo', 1 => 'bar']
```

##### firstsImmutable(null|int $take) : Arrayy (Immutable)

[](#firstsimmutablenullint-take--arrayy-immutable)

Get the first value(s) from the current array.

```
a([2 => 'foo', 3 => 'bar', 4 => 'lall'])->firsts(2); // Arrayy[0 => 'foo', 1 => 'bar']
```

##### flip() : Arrayy (Immutable)

[](#flip--arrayy-immutable)

Exchanges all keys with their associated values in an array.

```
a([0 => 'foo', 1 => 'bar'])->flip(); // Arrayy['foo' => 0, 'bar' => 1]
```

##### get(string $key, \[null $default\], \[null $array\]) : mixed

[](#getstring-key-null-default-null-array--mixed)

Get a value from an array (optional using dot-notation).

```
$arrayy = a(['user' => ['lastname' => 'Moelleken']]);
$arrayy->get('user.lastname'); // 'Moelleken'

// ---

$arrayy = new A();
$arrayy['user'] = ['lastname' => 'Moelleken'];
$arrayy['user.firstname'] = 'Lars';

$arrayy['user']['lastname'] // Moelleken
$arrayy['user.lastname'] // Moelleken
$arrayy['user.firstname'] // Lars
```

##### getColumn(mixed $columnKey, mixed $indexKey) : Arrayy

[](#getcolumnmixed-columnkey-mixed-indexkey--arrayy)

Returns the values from a single column of the input array, identified by the $columnKey, can be used to extract data-columns from multi-arrays.

```
a([['foo' => 'bar', 'id' => 1], ['foo => 'lall', 'id' => 2]])->getColumn('foo', 'id'); // Arrayy[1 => 'bar', 2 => 'lall']
```

##### getIterator()

[](#getiterator)

Returns a new ArrayyIterator, thus implementing the IteratorAggregate interface.

```
a(['foo', 'bar'])->getIterator(); // ArrayyIterator['foo', 'bar']
```

##### implode(string $with) : string

[](#implodestring-with--string)

Implodes an array.

```
a([0 => -9, 1, 2])->implode('|'); // '-9|1|2'
```

##### initial(int $to) : Arrayy (Immutable)

[](#initialint-to--arrayy-immutable)

Get everything but the last..$to items.

```
a([2 => 'foo', 3 => 'bar', 4 => 'lall'])->initial(2); // Arrayy[0 => 'foo']
```

##### intersection(array $search) : Arrayy (Immutable)

[](#intersectionarray-search--arrayy-immutable)

Return an array with all elements found in input array.

```
a(['foo', 'bar'])->intersection(['bar', 'baz']); // Arrayy['bar']
```

##### intersects(array $search) : boolean

[](#intersectsarray-search--boolean)

Return a boolean flag which indicates whether the two input arrays have any common elements.

```
a(['foo', 'bar'])->intersects(['föö', 'bär']); // false
```

##### isAssoc() : boolean

[](#isassoc--boolean)

Check if we have named keys in the current array.

```
a(['foo' => 'bar', 2, 3])->isAssoc(); // true
```

##### isEqual() : boolean

[](#isequal--boolean)

Check if we have named keys in the current array.

```
a(['💩'])->isEqual(['💩']); // true
```

##### isMultiArray() : boolean

[](#ismultiarray--boolean)

Check if the current array is a multi-array.

```
a(['foo' => [1, 2 , 3]])->isMultiArray(); // true
```

##### isSequential() : boolean

[](#issequential--boolean)

Check if the current array is sequential \[0, 1, 2, 3, 4, 5 ...\] or not.

```
a([0 => 'foo', 1 => 'lall', 2 => 'foobar'])->isSequential(); // true
```

##### keys() : Arrayy (Immutable)

[](#keys--arrayy-immutable)

Get all keys from the current array.

alias: "Arrayy-&gt;getKeys()"

```
$arrayy = a([1 => 'foo', 2 => 'foo2', 3 => 'bar']);
$arrayy->keys(); // Arrayy[1, 2, 3]
```

##### last() : mixed

[](#last--mixed)

Get the last value from the current array.

```
a([2 => 'foo', 3 => 'bar', 4 => 'lall'])->last(); // 'lall'
```

##### lastsImmutable(null|int $take) : Arrayy (Immutable)

[](#lastsimmutablenullint-take--arrayy-immutable)

Get the last value(s) from the current array.

```
a([2 => 'foo', 3 => 'bar', 4 => 'lall'])->lasts(2); // Arrayy[0 => 'bar', 1 => 'lall']
```

##### lastsMutable(null|int $take) : Arrayy (Mutable)

[](#lastsmutablenullint-take--arrayy-mutable)

Get the last value(s) from the current array.

```
a([2 => 'foo', 3 => 'bar', 4 => 'lall'])->lasts(2); // Arrayy[0 => 'bar', 1 => 'lall']
```

##### length() : int

[](#length--int)

Count the values from the current array.

alias: "Arrayy-&gt;count()" || "Arrayy-&gt;size()"

```
a([-9, -8, -7, 1.32])->length(); // 4
```

##### max() : mixed

[](#max--mixed)

Get the max value from an array.

```
a([-9, -8, -7, 1.32])->max(); // 1.32
```

##### matches(Closure $closure) : boolean

[](#matchesclosure-closure--boolean)

Check if all items in an array match a truth test.

```
$closure = function ($value, $key) {
  return ($value % 2 === 0);
};
a([2, 4, 8])->matches($closure); // true
```

##### matchesAny(Closure $closure) : boolean

[](#matchesanyclosure-closure--boolean)

Check if any item in an array matches a truth test.

```
$closure = function ($value, $key) {
  return ($value % 2 === 0);
};
a([1, 4, 7])->matches($closure); // true
```

##### mergeAppendKeepIndex(array $array) : Arrayy (Immutable)

[](#mergeappendkeepindexarray-array--arrayy-immutable)

Merge the new $array into the current array.

- keep key,value from the current array, also if the index is in the new $array

```
$array1 = [1 => 'one', 'foo' => 'bar1'];
$array2 = ['foo' => 'bar2', 3 => 'three'];
a($array1)->mergeAppendKeepIndex($array2); // Arrayy[1 => 'one', 'foo' => 'bar2', 3 => 'three']
```

##### mergePrependKeepIndex(array $array) : Arrayy (Immutable)

[](#mergeprependkeepindexarray-array--arrayy-immutable)

Merge the the current array into the $array.

- use key,value from the new $array, also if the index is in the current array

```
$array1 = [1 => 'one', 'foo' => 'bar1'];
$array2 = ['foo' => 'bar2', 3 => 'three'];
a($array1)->mergePrependKeepIndex($array2); // Arrayy['foo' => 'bar1', 3 => 'three', 1 => 'one']
```

##### mergeAppendNewIndex(array $array) : Arrayy (Immutable)

[](#mergeappendnewindexarray-array--arrayy-immutable)

Merge the new $array into the current array.

- replace duplicate assoc-keys from the current array with the key,values from the new $array
- create new indexes

```
$array1 = [1 => 'one', 'foo' => 'bar1'];
$array2 = ['foo' => 'bar2', 3 => 'three'];
a($array1)->mergeAppendNewIndex($array2); // Arrayy[0 => 'one', 'foo' => 'bar2', 1 => three']
```

##### mergePrependNewIndex(array $array) : Arrayy (Immutable)

[](#mergeprependnewindexarray-array--arrayy-immutable)

Merge the current array into the new $array.

- replace duplicate assoc-keys from new $array with the key,values from the current array
- create new indexes

```
$array1 = [1 => 'one', 'foo' => 'bar1'];
$array2 = ['foo' => 'bar2', 3 => 'three'];
a($array1)->mergePrependNewIndex($array2); // Arrayy['foo' => 'bar1', 0 => 'three', 1 => 'one']
```

##### min() : mixed

[](#min--mixed)

Get the min value from an array.

```
a([-9, -8, -7, 1.32])->min(); // -9
```

##### moveElement(int|string $from, int|string $to) : Arrayy

[](#moveelementintstring-from-intstring-to--arrayy)

Move an array element to a new index.

```
$arr2 = new A(['A' => 'a', 'B' => 'b', 'C' => 'c', 'D' => 'd', 'E' => 'e']);
$newArr2 = $arr2->moveElement('D', 1); // Arrayy['A' => 'a', 'D' => 'd', 'B' => 'b', 'C' => 'c', 'E' => 'e']
```

##### randomKey() : mixed

[](#randomkey--mixed)

Pick a random key/index from the keys of this array.

alias: "Arrayy-&gt;getRandomKey()"

```
$arrayy = A::create([1 => 'one', 2 => 'two']);
$arrayy->randomKey(); // e.g. 2
```

##### randomKeys() : Arrayy (Immutable)

[](#randomkeys--arrayy-immutable)

Pick a given number of random keys/indexes out of this array.

alias: "Arrayy-&gt;getRandomKeys()"

```
$arrayy = A::create([1 => 'one', 2 => 'two']);
$arrayy->randomKeys(); // e.g. Arrayy[1, 2]
```

##### randomValue() : mixed

[](#randomvalue--mixed)

Pick a random value from the values of this array.

alias: "Arrayy-&gt;getRandomValue()"

```
$arrayy = A::create([1 => 'one', 2 => 'two']);
$arrayy->randomValue(); // e.g. 'one'
```

##### randomValues() : Arrayy (Immutable)

[](#randomvalues--arrayy-immutable)

Pick a given number of random values out of this array.

alias: "Arrayy-&gt;getRandomValues()"

```
$arrayy = A::create([1 => 'one', 2 => 'two']);
$arrayy->randomValues(); // e.g. Arrayy['one', 'two']
```

##### randomImmutable(int|null $take) : Arrayy (Immutable)

[](#randomimmutableintnull-take--arrayy-immutable)

Get a random string from an array.

alias: "Arrayy-&gt;getRandom()"

```
a([1, 2, 3, 4])->randomImmutable(2); // e.g.: Arrayy[1, 4]
```

##### randomMutable(int|null $take) : Arrayy (Mutable)

[](#randommutableintnull-take--arrayy-mutable)

Get a random string from an array.

```
a([1, 2, 3, 4])->randomMutable(2); // e.g.: Arrayy[1, 4]
```

##### randomWeighted(array $array, int|null $take) : Arrayy (Immutable)

[](#randomweightedarray-array-intnull-take--arrayy-immutable)

Get a random value from an array, with the ability to skew the results.

```
a([0 => 3, 1 => 4])->randomWeighted([1 => 4]); // e.g.: Arrayy[4] (has a 66% chance of returning 4)
```

##### reduce(callable $predicate, array $init) : Arrayy (Immutable)

[](#reducecallable-predicate-array-init--arrayy-immutable)

Reduce the current array via callable e.g. anonymous-function.

```
function myReducer($resultArray, $value) {
  if ($value == 'foo') {
    $resultArray[] = $value;
  }
  return $resultArray;
};
a(['foo', 'bar'])->reduce('myReducer'); // Arrayy['foo']
```

##### reindex() : Arrayy (Mutable)

[](#reindex--arrayy-mutable)

Create a numerically re-indexed Arrayy object.

```
a([2 => 1, 3 => 2])->reindex(); // Arrayy[0 => 1, 1 => 2]
```

##### reject(Closure $closure) : Arrayy (Immutable)

[](#rejectclosure-closure--arrayy-immutable)

Return all items that fail the truth test.

```
$closure = function ($value) {
  return $value % 2 !== 0;
}
a([1, 2, 3, 4])->reject($closure); // Arrayy[1 => 2, 3 => 4]
```

##### remove(mixed $key) : (Immutable)

[](#removemixed-key--immutable)

Remove a value from the current array (optional using dot-notation).

```
a([1 => 'bar', 'foo' => 'foo'])->remove(1); // Arrayy['foo' => 'foo']
```

##### removeFirst() : Arrayy (Immutable)

[](#removefirst--arrayy-immutable)

Remove the first value from the current array.

```
a([1 => 'bar', 'foo' => 'foo'])->removeFirst(); // Arrayy['foo' => 'foo']
```

##### removeLast() : Arrayy (Immutable)

[](#removelast--arrayy-immutable)

Remove the last value from the current array.

```
a([1 => 'bar', 'foo' => 'foo'])->removeLast(); // Arrayy[1 => 'bar']
```

##### removeValue(mixed $value) : Arrayy (Immutable)

[](#removevaluemixed-value--arrayy-immutable)

Removes a particular value from an array (numeric or associative).

```
a([1 => 'bar', 'foo' => 'foo'])->removeValue('foo'); // Arrayy[1 => 'bar']
```

##### replace(array $keys) : Arrayy (Immutable)

[](#replacearray-keys--arrayy-immutable)

Replace a key with a new key/value pair.

```
$arrayy = a([1 => 'foo', 2 => 'foo2', 3 => 'bar']);
$arrayy->replace(2, 'notfoo', 'notbar'); // Arrayy[1 => 'foo', 'notfoo' => 'notbar', 3 => 'bar']
```

##### replaceAllKeys(array $keys) : Arrayy (Immutable)

[](#replaceallkeysarray-keys--arrayy-immutable)

Create an array using the current array as values and the other array as keys.

```
$firstArray = array(
    1 => 'one',
    2 => 'two',
    3 => 'three',
);
$secondArray = array(
    'one' => 1,
    1     => 'one',
    2     => 2,
);
$arrayy = a($firstArray);
$arrayy->replaceAllKeys($secondArray); // Arrayy[1 => "one", 'one' => "two", 2 => "three"]
```

##### replaceAllValues(array $array) : Arrayy (Immutable)

[](#replaceallvaluesarray-array--arrayy-immutable)

Create an array using the current array as keys and the other array as values.

```
$firstArray = array(
    1 => 'one',
    2 => 'two',
    3 => 'three',
);
$secondArray = array(
    'one' => 1,
    1     => 'one',
    2     => 2,
);
$arrayy = a($firstArray);
$arrayy->replaceAllValues($secondArray); // Arrayy['one' => 1, 'two' => 'one', 'three' => 2]
```

##### replaceKeys(array $keys) : Arrayy (Immutable)

[](#replacekeysarray-keys--arrayy-immutable)

Replace the keys in an array with another set.

WARNING: An array of keys must matching the array's size and order!

```
a([1 => 'bar', 'foo' => 'foo'])->replaceKeys([1 => 2, 'foo' => 'replaced']); // Arrayy[2 => 'bar', 'replaced' => 'foo']
```

##### replaceOneValue(mixed $search, mixed $replacement) : Arrayy (Immutable)

[](#replaceonevaluemixed-search-mixed-replacement--arrayy-immutable)

Replace the first matched value in an array.

```
$testArray = ['bar', 'foo' => 'foo', 'foobar' => 'foobar'];
a($testArray)->replaceOneValue('foo', 'replaced'); // Arrayy['bar', 'foo' => 'replaced', 'foobar' => 'foobar']
```

##### replaceValues(string $search, string $replacement) : Arrayy (Immutable)

[](#replacevaluesstring-search-string-replacement--arrayy-immutable)

Replace values in the current array.

```
$testArray = ['bar', 'foo' => 'foo', 'foobar' => 'foobar'];
a($testArray)->replaceValues('foo', 'replaced'); // Arrayy['bar', 'foo' => 'replaced', 'foobar' => 'replacedbar']
```

##### rest(int $from) : Arrayy (Immutable)

[](#restint-from--arrayy-immutable)

Get the last elements from index $from until the end of this array.

```
a([2 => 'foo', 3 => 'bar', 4 => 'lall'])->rest(2); // Arrayy[0 => 'lall']
```

##### reverse() : Arrayy (Mutable)

[](#reverse--arrayy-mutable)

Return the array in the reverse order.

```
a([1, 2, 3])->reverse(); // self[3, 2, 1]
```

##### searchIndex(mixed $value) : mixed

[](#searchindexmixed-value--mixed)

Search for the first index of the current array via $value.

```
a(['fòô' => 'bàř', 'lall' => 'bàř'])->searchIndex('bàř'); // Arrayy[0 => 'fòô']
```

##### searchValue(mixed $index) : Arrayy (Immutable)

[](#searchvaluemixed-index--arrayy-immutable)

Search for the value of the current array via $index.

```
a(['fòô' => 'bàř'])->searchValue('fòô'); // Arrayy[0 => 'bàř']
```

##### set(mixed $key, mixed $value) : Arrayy (Immutable)

[](#setmixed-key-mixed-value--arrayy-immutable)

Set a value for the current array (optional using dot-notation).

```
$arrayy = a(['Lars' => ['lastname' => 'Moelleken']]);
$arrayy->set('Lars.lastname', 'Müller'); // Arrayy['Lars', ['lastname' => 'Müller']]]
```

##### setAndGet()

[](#setandget)

Get a value from a array and set it if it was not.

WARNING: this method only set the value, if the $key is not already set

```
$arrayy = a([1 => 1, 2 => 2, 3 => 3]);
$arrayy->setAndGet(1, 4); // 1
$arrayy->setAndGet(0, 4); // 4
```

##### serialize() : string

[](#serialize--string)

Serialize the current arrayy-object.

```
a([1, 4, 7])->serialize();
```

##### unserialize(string $string) : Arrayy (Mutable)

[](#unserializestring-string--arrayy-mutable)

Unserialize an string and return this object.

```
$serialized = a([1, 4, 7])->serialize();
a()->unserialize($serialized);
```

##### sort(string|int(SORT\_ASC) $direction, int(SORT\_REGULAR) $strategy, bool(false) $keepKeys) : Arrayy (Mutable)

[](#sortstringintsort_asc-direction-intsort_regular-strategy-boolfalse-keepkeys--arrayy-mutable)

Sort the current array and optional you can keep the keys.

- $direction e.g.: \[SORT\_ASC, SORT\_DESC, 'ASC', 'asc', 'DESC', 'desc'\]
- $strategy e.g.: \[SORT\_REGULAR, SORT\_NATURAL, ...\]

```
a(3 => 'd', 2 => 'f', 0 => 'a')->sort(SORT_ASC, SORT_NATURAL, false); // Arrayy[0 => 'a', 1 => 'd', 2 => 'f']
```

##### sorter(null|callable $sorter, string|int(SORT\_ASC) $direction, int(SORT\_REGULAR) $strategy) : Arrayy (Immutable)

[](#sorternullcallable-sorter-stringintsort_asc-direction-intsort_regular-strategy--arrayy-immutable)

Sort a array by value, by a closure or by a property.

- If the sorter is null (default), the array is sorted naturally.
- Associative (string) keys will be maintained, but numeric keys will be re-indexed.
- $direction e.g.: \[SORT\_ASC, SORT\_DESC, 'ASC', 'asc', 'DESC', 'desc'\]
- $strategy e.g.: \[SORT\_REGULAR, SORT\_NATURAL, ...\]

```
$testArray = range(1, 5);
$under = a($testArray)->sorter(
  function ($value) {
    return $value % 2 === 0;
  }
);
var_dump($under); // Arrayy[1, 3, 5, 2, 4]
```

##### sortKeys(string|int(SORT\_ASC) $direction) : Arrayy (Mutable)

[](#sortkeysstringintsort_asc-direction--arrayy-mutable)

Sort the current array by key by $direction = 'asc' or $direction = 'desc'.

- $direction e.g.: \[SORT\_ASC, SORT\_DESC, 'ASC', 'asc', 'DESC', 'desc'\]

```
a([1 => 2, 0 => 1])->sortKeys('asc'); // Arrayy[0 => 1, 1 => 2]
```

##### sortValueNewIndex(string|int(SORT\_ASC) $direction, int(SORT\_REGULAR) $strategy) : Arrayy (Immutable)

[](#sortvaluenewindexstringintsort_asc-direction-intsort_regular-strategy--arrayy-immutable)

Sort the current array by value.

- $direction e.g.: \[SORT\_ASC, SORT\_DESC, 'ASC', 'asc', 'DESC', 'desc'\]
- $strategy e.g.: \[SORT\_REGULAR, SORT\_NATURAL, ...\]

```
a(3 => 'd', 2 => 'f', 0 => 'a')->sortValueNewIndex(SORT_ASC, SORT_NATURAL); // Arrayy[0 => 'a', 1 => 'd', 2 => 'f']
```

##### sortValueKeepIndex(string|int(SORT\_ASC) $direction, int(SORT\_REGULAR) $strategy) : Arrayy (Immutable)

[](#sortvaluekeepindexstringintsort_asc-direction-intsort_regular-strategy--arrayy-immutable)

Sort the current array by value.

- $direction e.g.: \[SORT\_ASC, SORT\_DESC, 'ASC', 'asc', 'DESC', 'desc'\]
- $strategy e.g.: \[SORT\_REGULAR, SORT\_NATURAL, ...\]

```
a(3 => 'd', 2 => 'f', 0 => 'a')->sortValueNewIndex(SORT_ASC, SORT_REGULAR); // Arrayy[0 => 'a', 3 => 'd', 2 => 'f']
```

##### split(int(2) $numberOfPieces, bool(false) $keepKeys) : Arrayy (Immutable)

[](#splitint2-numberofpieces-boolfalse-keepkeys--arrayy-immutable)

Split an array in the given amount of pieces.

```
a(['a' => 1, 'b' => 2])->split(2, true); // Arrayy[['a' => 1], ['b' => 2]]
```

##### stripEmpty() : Arrayy (Immutable)

[](#stripempty--arrayy-immutable)

Stripe all empty items.

```
a(['a' => 1, 'b' => ''])->stripEmpty(); // Arrayy[['a' => 1]]
```

##### swap(string|int $swapA, string|int $swapB) : Arrayy (Immutable)

[](#swapstringint-swapa-stringint-swapb--arrayy-immutable)

Swap two values between positions by key.

```
a(['a' => 1, 'b' => ''])->swap('a', 'b'); // Arrayy[['a' => '', 'b' => 1]]
```

##### shuffle() : Arrayy (Immutable)

[](#shuffle--arrayy-immutable)

Shuffle the current array.

```
a([1 => 'bar', 'foo' => 'foo'])->shuffle(); // e.g.: Arrayy[['foo' => 'foo', 1 => 'bar']]
```

##### toJson() : string

[](#tojson--string)

Convert the current array to JSON.

```
a(['bar', array('foo')])->toJson(); // '["bar",{"1":"foo"}]'
```

##### uniqueNewIndex() : Arrayy (Mutable)

[](#uniquenewindex--arrayy-mutable)

Return a duplicate free copy of the current array.

```
a([2 => 1, 3 => 2, 4 => 2])->uniqueNewIndex(); // Arrayy[1, 2]
```

##### uniqueKeepIndex() : Arrayy (Mutable)

[](#uniquekeepindex--arrayy-mutable)

Return a duplicate free copy of the current array.

```
a([2 => 1, 3 => 2, 4 => 2])->uniqueNewIndex(); // Arrayy[2 => 1, 3 => 2]
```

##### values() : Arrayy (Immutable)

[](#values--arrayy-immutable)

Get all values from a array.

```
$arrayy = a([1 => 'foo', 2 => 'foo2', 3 => 'bar']);
$arrayyTmp->values(); // Arrayy[0 => 'foo', 1 => 'foo2', 2 => 'bar']
```

##### walk() : Arrayy (Mutable)

[](#walk--arrayy-mutable)

Apply the given function to every element in the array, discarding the results.

```
$callable = function (&$value, $key) {
  $value = $key;
};
$arrayy = a([1, 2, 3]);
$arrayy->walk($callable); // Arrayy[0, 1, 2]
```

Tests
-----

[](#tests)

From the project directory, tests can be ran using `phpunit`

License
-------

[](#license)

Released under the MIT License - see `LICENSE.txt` for details.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 95.5% 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 ~16 days

Recently: every ~31 days

Total

36

Last Release

3245d ago

Major Versions

1.2.0 → 2.0.02016-02-10

2.2.9 → 3.0.02017-01-06

### Community

Maintainers

![](https://www.gravatar.com/avatar/db7299473afa8a93d6beb49c5c9c31a6d58efb07c74a91eae71c77f9c1786fd8?d=identicon)[parfumix](/maintainers/parfumix)

---

Top Contributors

[![voku](https://avatars.githubusercontent.com/u/264695?v=4)](https://github.com/voku "voku (126 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (3 commits)")[![parfumix](https://avatars.githubusercontent.com/u/6368534?v=4)](https://github.com/parfumix "parfumix (2 commits)")[![dvdmarchetti](https://avatars.githubusercontent.com/u/1494034?v=4)](https://github.com/dvdmarchetti "dvdmarchetti (1 commits)")

---

Tags

arrayutilityhelpersmanipulationutilsmethodsArrayy

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/parfumix-arrayy/health.svg)

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

###  Alternatives

[voku/arrayy

Array manipulation library for PHP, called Arrayy!

4885.6M18](/packages/voku-arrayy)[danielstjules/stringy

A string manipulation library with multibyte support

2.4k26.2M192](/packages/danielstjules-stringy)[voku/stringy

A string manipulation library with multibyte support

1793.9M24](/packages/voku-stringy)[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k417.9M1.7k](/packages/nette-utils)[statamic/stringy

A string manipulation library with multibyte support, forked from @statamic

244.8M17](/packages/statamic-stringy)[jbzoo/utils

Collection of PHP functions, mini classes and snippets for everyday developer's routine life.

8161.6M36](/packages/jbzoo-utils)

PHPackages © 2026

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