PHPackages                             opxcore/array - 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. opxcore/array

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

opxcore/array
=============

The OpxCore array utils.

1.2.0(5y ago)11412MITPHPPHP ^7.4CI failing

Since Jan 13Pushed 5y agoCompare

[ Source](https://github.com/opxcore/array)[ Packagist](https://packagist.org/packages/opxcore/array)[ RSS](/packages/opxcore-array/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (4)Dependencies (1)Versions (8)Used By (2)

Array utils
===========

[](#array-utils)

[![Build Status](https://camo.githubusercontent.com/954c3592f55a00fbdbcb6790c6689ff8165ad9fd88fbd5b5cc6b5a86b0af9eef/68747470733a2f2f7472617669732d63692e636f6d2f6f7078636f72652f61727261792e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/opxcore/array)[![Coverage Status](https://camo.githubusercontent.com/aa4ef818d76363e5737ed2a56c865be9e383342bb7a917cf2220889d8e55539d/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6f7078636f72652f61727261792f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/opxcore/array?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/4e53194354abad6f05b570f2d934c2f60871c41822bf749ab914bc8e1bf56584/68747470733a2f2f706f7365722e707567782e6f72672f6f7078636f72652f61727261792f762f737461626c65)](https://packagist.org/packages/opxcore/array)[![Total Downloads](https://camo.githubusercontent.com/ab941aea6fbbbdce07b5c1fd7c9c1f1448ffbd4f8750dd772ba845d6dae273b8/68747470733a2f2f706f7365722e707567782e6f72672f6f7078636f72652f61727261792f646f776e6c6f616473)](https://packagist.org/packages/opxcore/array)[![License](https://camo.githubusercontent.com/07091ce981f3d9049cbfa233d0bf201ce3af6f2fc4532b7b9610817985bf1893/68747470733a2f2f706f7365722e707567782e6f72672f6f7078636f72652f61727261792f6c6963656e7365)](https://packagist.org/packages/opxcore/array)

Installing
----------

[](#installing)

```
composer require opxcore/array

```

Usage
-----

[](#usage)

Available methods:

For dot notation:

- `OpxCore\Arr\Arr::dot($array)`
- `OpxCore\Arr\Arr::get($array, $key, $default)`
- `OpxCore\Arr\Arr::set($array, $key, $value)`
- `OpxCore\Arr\Arr::has($array, $keys)`
- `OpxCore\Arr\Arr::forget($array, $keys)`
- `OpxCore\Arr\Arr::pull($array, $key, $default)`
- `OpxCore\Arr\Arr::push($array, $key, $value)`

Regular arrays only:

- `OpxCore\Arr\Arr::only($array, $keys)`
- `OpxCore\Arr\Arr::first($array, $callback, $default)`
- `OpxCore\Arr\Arr::last($array, $callback, $default)`

All `$default` values are optional and could be `callable` that returns value. By default, it is always `null`.

***Performance tips:** All methods for manipulating with dot notation are optimised for performance on a dot notated keys. **If you are care about performance** much it is better to use regular array manipulations on non-dot notated arrays.*

### Making a dot notated array

[](#making-a-dot-notated-array)

```
$dotNotated = Arr::dot($array);
```

Makes a dot notated array from any flat or multidimensional array.

```
    $array = ['level1' => ['level2' => 'value']];

    $result = Arr::dot($array);
    // $result === ['level1.level2' => 'value']
```

### Getting a value using dot notation

[](#getting-a-value-using-dot-notation)

```
OpxCore\Arr\Arr::get($array, $key, $default = null)
```

Gets a value from the array using dot notation. If the given key is not existing in the array, this function will return default value.

```
    use OpxCore\Arr\Arr;

    $array = ['level1' => ['level2' => 'value']];

    $result = Arr::get($array, 'level1.level2');
    // $result === 'value'

    $result = Arr::get($array, 'level1.level3');
    // $result === null

    $result = Arr::get($array, 'level1.level3', false);
    // $result === false

    $result = Arr::get($array, 'level1.level3', function(){return -1;});
    // $result === -1
```

### Setting a value using dot notation

[](#setting-a-value-using-dot-notation)

```
OpxCore\Arr\Arr::set($array, $key, $value): array
```

Sets the value into the array for the given key using dot notation. Function modifies given array directly, but also returns modified array for convenient usage.

```
    use OpxCore\Arr\Arr;

    $array = ['level1' => ['level2' => 'value']];

    $result = Arr::set($array, 'level1.level2_1', 'another value');
    // $result === ['level1' => ['level2' => 'value', 'level2_1' => 'another value']]
    // $array === $result
```

### Determining a key (or keys) existence in the array

[](#determining-a-key-or-keys-existence-in-the-array)

```
OpxCore\Arr\Arr::has($array, $keys)
```

Determines if the given key (or several keys) are existing in the array.

```
    use OpxCore\Arr\Arr;

    $array = ['level1' => ['level2' => 'value', 'level2_1' => 'another value']];

    $result = Arr::has($array, 'level1.level2');
    // $result === true

    $result = Arr::has($array, ['level1.level2', 'level1.level2_2']);
    // $result === false
```

### Removing the values associated with the given keys

[](#removing-the-values-associated-with-the-given-keys)

```
OpxCore\Arr\Arr::forget($array, $keys)
```

Removes the given key (or several keys given as an array) from the array. If any of keys are not existing in the array nothing happens. Function modifies given array directly, but also returns modified array for convenient usage.

```
    use OpxCore\Arr\Arr;

    $array = ['level1' => ['level2' => 'value', 'level2_1' => 'another value']];

    $result = Arr::forget($array, 'level1.level2');
    // $result === ['level1' => ['level2_1' => 'another value']]
    // $array === $result
```

### Pulling the value from the array

[](#pulling-the-value-from-the-array)

```
OpxCore\Arr\Arr::pull($array, $key, $default)
```

Actually, this is combination of `Arr::get()` and `Arr::forget()` methods. This method fetches the value and then removes it from the array. If the key is not exists in the array, default value will be returned.

```
    use OpxCore\Arr\Arr;

    $array = ['level1' => ['level2' => 'value', 'level2_1' => 'another value']];

    $result = Arr::pull($array, 'level1.level2');
    // $result === 'value'
    // $array === ['level1' => ['level2_1' => 'another value']]
```

### Pushing the value into the array

[](#pushing-the-value-into-the-array)

```
OpxCore\Arr\Arr::push($array, $key, $value)
```

Pushes the value into the given key in array. If given key is not existing, it will be created and the value will be set as item of unassociated array. If the key is existing, value associated with this key will be casted as array and value will be added into it. Function modifies given array directly, but also returns modified array for convenient usage.

```
        use OpxCore\Arr\Arr;

        $array = ['level1' => ['level2' => 'value']];

        $result = Arr::push($array, 'level1.level2', 'another value');
        // $result === ['level1' => ['level2' => ['value', 'another value']]]
        // $array === $result
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 83.3% 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 ~118 days

Recently: every ~176 days

Total

7

Last Release

1971d ago

Major Versions

0.3.1 → 1.02019-01-17

PHP version history (2 changes)0.2PHP ^7.1.3

1.2.0PHP ^7.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/46634185?v=4)[opxcore](/maintainers/opxcore)[@opxcore](https://github.com/opxcore)

---

Top Contributors

[![lozovoyv](https://avatars.githubusercontent.com/u/21274927?v=4)](https://github.com/lozovoyv "lozovoyv (25 commits)")[![opxcore](https://avatars.githubusercontent.com/u/46634185?v=4)](https://github.com/opxcore "opxcore (5 commits)")

---

Tags

arraydot notation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/opxcore-array/health.svg)

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

###  Alternatives

[doctrine/collections

PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.

6.0k411.1M1.2k](/packages/doctrine-collections)[symfony/property-access

Provides functions to read and write from/to an object or array using a simple string notation

2.8k295.3M2.5k](/packages/symfony-property-access)[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.1k394.3M1.5k](/packages/nette-utils)[league/config

Define configuration arrays with strict schemas and access values with dot notation

564302.2M24](/packages/league-config)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[openlss/lib-array2xml

Array2XML conversion library credit to lalit.org

31052.5M47](/packages/openlss-lib-array2xml)

PHPackages © 2026

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