PHPackages                             northern/common - 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. northern/common

ActiveLibrary

northern/common
===============

PHP Helpers.

2.0.8(7y ago)1059624GPL-2.0-onlyPHPPHP &gt;=5.3.3

Since Apr 10Pushed 7y ago2 watchersCompare

[ Source](https://github.com/northern/PHP-Common)[ Packagist](https://packagist.org/packages/northern/common)[ RSS](/packages/northern-common/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (2)Versions (21)Used By (4)

PHP Common
==========

[](#php-common)

[![Build Status](https://camo.githubusercontent.com/4adce19f1d8f05462f6c9ec9951d8c8052ac18fc39b79746e42056de3eb80265/68747470733a2f2f7472617669732d63692e6f72672f6e6f72746865726e2f5048502d436f6d6d6f6e2e706e673f6272616e63683d6465762d6d6173746572)](https://travis-ci.org/northern/PHP-Common)

PHP Common is a PHP library containing a set of common functionality.

To run tests use:

```
composer install -v

vendor/bin/phpunit

```

Find PHP Common on [Packagist](https://packagist.org/packages/northern/common):

ArrayUtil
---------

[](#arrayutil)

To use `ArrayUtil` you need to import it.

```
use Northern\Common\Util\ArrayUtil as Arr;
```

### get

[](#get)

To get a value from an array use `get`:

```
$a = array(
   'foo' => 'bar'
);

$value = Arr::get( $a, 'foo' );

// $value == 'bar'
```

You can specify a default value in case the key you're trying to retrieve doesn't exists:

```
$value = Arr::get( $a, 'baz', NULL );

// $value == NULL
```

To get a nested value from an array you can specify a path:

```
$a = array(
   'foo' => array(
      'bar' => array(
         'baz' => 123
      )
   )
);

$value = Arr::get( $a, 'foo.bar.baz' );

// $value == 123
```

If required, you can use an alternate delimiter:

```
$value = Arr::getPath( $a, 'foo/bar/baz', NULL, '/' );

// $value == 123
```

### set

[](#set)

To set a value or nested value use the `set` method:

```
$a = array();

Arr::set( $a, 'foo.bar.baz', 123 );

// $a = array( 'foo' => array( 'bar' => array( 'baz' => 123 ) ) );
```

If the key or path not already exist, it will be created.

### insert

[](#insert)

With `insert` you can create a new value at a path or key, however, the path will only be created if it does not yet exists.

```
$a = array();

Arr::set( $a, 'foo.bar.baz', 123 );

Arr::insert( $a, 'foo.bar.baz', 123 );

// The insert statement does nothing.
```

### delete

[](#delete)

It's also possible to delete a key or path:

```
Arr::delete( $a, 'foo.bar.baz' );
```

Or to delete multiple paths or keys at once:

```
Arr::delete( $a, array('fum', 'foo.bar.baz', 'foo.bar.bob') );
```

Or with an alternate delimiter:

```
Arr::delete( $a, array('fum', 'foo/bar/baz', 'foo/bar/bob'), '/' );
```

### exists

[](#exists)

To test if a key or path exists use:

```
$value = Arr::exists( $a, 'foo.bar.baz' );

// $value == TRUE
```

### prefix

[](#prefix)

If you need to prefix all the values in an array, use the `prefix` method:

```
$a = array('1', '2', '3');

$values = Arr::prefix( $a, '$' );

// $values = array('$1', '$2', '$3');
```

### postfix

[](#postfix)

If you need to postfix all the values in an array, use the `postfix` method:

```
$a = array('1', '2', '3');

$values = Arr::postfix( $a, '$' );

// $values = array('1$', '2$', '3$');
```

### flatten

[](#flatten)

Sometimes you need to "flatten" an array, i.e. glueing the keys and values together with a symbol or character:

```
$a = array('param1' => '123', 'param2' => 'xyz');

$values = Arr::flatten( $a );

// $values = array('param1=123', 'param2=xyz');
```

Or use a different 'glue' character from the default '=':

```
$values = Arr::flatten( $a, '|' );

// $values = array( 'param1|123', 'param2|xyz' );
```

### keys

[](#keys)

Returns the keys of an array in the same way the `array_keys` function works, however, `keys` allows you to specifiy a prefix:

```
$a = array('param1' => '123', 'param2' => 'xyz');

$values = Arr::keys( $a, '&' );

// $values = array( '&param1', '&param2' )
```

### values

[](#values)

Returns the values of an array in the same way the `array_values` function works, however, `values` allows you to specify a prefix:

```
$a = array('param1' => '123', 'param2' => 'xyz');

$values = Arr::values( $a, '&' );

// $values = array( '&123', '&xyz' )
```

### contains

[](#contains)

Tests if the values of one array exist in another. E.g:

```
$b = Arr::contains( array('A', 'B'), array('A', 'B', 'C') );

// $b = TRUE
```

The above tests if the values of the first array (needle) exist in the second array (haystack), which in the above example is true.

### extract

[](#extract)

Returns a value from an array and deletes the key in the array.

```
$a = array(
   'foo' => 'bar'
);

$value = Arr::extract( $a, 'foo' );

// $value == 'bar'
// $a = array()
```

The above example returns the value for `foo` from the array and deletes the `foo` key from the array.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity67

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~88 days

Recently: every ~119 days

Total

18

Last Release

2906d ago

Major Versions

1.2.6 → 2.0.02016-02-04

### Community

Maintainers

![](https://www.gravatar.com/avatar/92f7c0328282deaf59b050a0448ff82eafe57e1e7c16ba952daad326e1aaeabc?d=identicon)[northern](/maintainers/northern)

---

Top Contributors

[![northern](https://avatars.githubusercontent.com/u/547843?v=4)](https://github.com/northern "northern (74 commits)")

---

Tags

phpphp-libraryhelperscommonnorthern

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/northern-common/health.svg)

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

###  Alternatives

[doctrine/common

PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects depend on such as better reflection support, proxies and much more.

5.8k363.3M1.2k](/packages/doctrine-common)[php-http/client-common

Common HTTP Client implementations and tools for HTTPlug

1.0k225.5M571](/packages/php-http-client-common)[laravel/helpers

Provides backwards compatibility for helpers in the latest Laravel release.

80660.2M458](/packages/laravel-helpers)

PHPackages © 2026

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