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

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

jdrieghe/array-helpers
======================

A collection of convenience methods to deal with arrays in php. Somewhat inspired by Laravel array helpers.

v0.2.0(7y ago)17468.7k↓20.3%32MITPHP

Since Oct 13Pushed 7y ago1 watchersCompare

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

READMEChangelog (2)Dependencies (2)Versions (3)Used By (2)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/5542de186593a839c9d1e7b201e9df78c641726ef9a12e36bc942011643c4d51/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a647269656768652f61727261792d68656c706572732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jdrieghe/array-helpers/?branch=master)[![Build Status](https://camo.githubusercontent.com/dd5e2ca69606c4d5625e8bd25701405489eec71c9f51c03315bddc40bbea640f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a647269656768652f61727261792d68656c706572732f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jdrieghe/array-helpers/build-status/master)[![Code Coverage](https://camo.githubusercontent.com/e9c94f0f8d6da60ab68b83c96ac068dc716fcaddffa530ba626b2b160917c0d8/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a647269656768652f61727261792d68656c706572732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jdrieghe/array-helpers/?branch=master)[![CircleCI](https://camo.githubusercontent.com/7052c5baf667d1f2e5772ba0052253b1fbc07b43ac187b5ac5d898d5ba15c86c/68747470733a2f2f636972636c6563692e636f6d2f67682f6a647269656768652f61727261792d68656c706572732f747265652f6d61737465722e7376673f7374796c653d736869656c64)](https://circleci.com/gh/jdrieghe/array-helpers/tree/master)[![License: MIT](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](https://github.com/jdrieghe/array-helpers/blob/master/LICENSE)

Purpose
-------

[](#purpose)

This package was inspired by some of the great array helper functions in Laravel.

Having to include all of `Illuminate\Support` is sometimes a bit too much for a given project, so I decided to build a separate package to provide some much needed framework independent array magic.

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

[](#installation)

Installation can be done easily through composer.

```
composer require jdrieghe/array-helpers

```

Usage
-----

[](#usage)

### Static approach

[](#static-approach)

You can choose to use only the static helper methods.

```
use ArrayHelpers\Arr;

$result = Arr::get($array, $key, $default);

```

### Functional approach

[](#functional-approach)

If you prefer a more functional approach, some namespaced convenience methods are available as well:

```
use function ArrayHelpers\array_get;

$result = array_get($array, $key, $default);

```

### Available helpers

[](#available-helpers)

#### Array Get

[](#array-get)

This helper allows you to get an item from an array using dot notation. If the item is not found, it will return a given default or null.

```
$data = [
    'foo' => [
        'bar' => 'baz',
    ],
];

Arr::get($data, 'foo');
// returns: ['bar' => 'baz'];

Arr::get($data, 'foo.bar');
// returns: 'baz';

Arr::get($data, 'xyz', 'default');
// returns: 'default';

```

Note that `Arr::get()` can be replaced with `array_get()` if you prefer a functional approach.

#### Array Has

[](#array-has)

This helper checks if an item exists in an array using dot notation.

```
$data = [
    'foo' => [
        'bar' => 'baz',
    ],
];

Arr::has($data, 'foo');
// returns: true;

Arr::has($data, 'foo.bar');
// returns: true;

Arr::has($data, 'xyz');
// returns: false;

```

Note that `Arr::has()` can be replaced with `array_has()` if you prefer a functional approach.

#### Array Set

[](#array-set)

This helper sets a certain key in an array to a certain value. Dot notation can be used to create a deeply nested key.

```
$data = [];
Arr::set($data, 'foo.bar', 'baz');

```

`$data` now contains:

```
[
    'foo' => [
        'bar' => 'baz',
    ],
];

```

Note that `Arr::set()` can be replaced with `array_set()` if you prefer a functional approach.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.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 ~276 days

Total

2

Last Release

2862d ago

### Community

Maintainers

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

---

Top Contributors

[![jdrieghe](https://avatars.githubusercontent.com/u/12606789?v=4)](https://github.com/jdrieghe "jdrieghe (41 commits)")[![dcsg](https://avatars.githubusercontent.com/u/744921?v=4)](https://github.com/dcsg "dcsg (1 commits)")[![jenssegers](https://avatars.githubusercontent.com/u/194377?v=4)](https://github.com/jenssegers "jenssegers (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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