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

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

berdidajohnlouise/array-helper
==============================

A convenient way use arrays in php.

11PHP

Since Jul 3Pushed 2y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

[![Array Helper Test](https://github.com/berdidajohnlouise/array-helper/actions/workflows/test.yml/badge.svg)](https://github.com/berdidajohnlouise/array-helper/actions/workflows/test.yml)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://github.com/berdidajohnlouise/array-helper/blob/main/LICENSE)

ArrayHelper - Simplify Array Operations in PHP.
===============================================

[](#arrayhelper---simplify-array-operations-in-php)

ArrayHelper is a powerful PHP package that provides a collection of functions to simplify common array operations, making array manipulation a breeze.

With ArrayHelper, you can perform various tasks such as sorting arrays, merging arrays, retreiving values by keys, checking array presence or emptiness and manipulating aray structures.

Features
--------

[](#features)

- sort() - Easily sort arrays based on properties or values in both ascending and descending order.
- merge() - Merge multiple arrays into a single array, combining their elements.
- get() - Retrieve values from arrays using keys or complex paths.
- has() - Determine if an array contains a specific key or value.
- Support for Associative and Indexed Arrays: Arrayhelper works seamlessly with both associative and indexed arrays.

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

[](#installation)

You can install the ArrayHelper package via Composer. Run the following command in your terminal:

```
    $ composer require berdidajohnlouise/array-helper
```

Usage
-----

[](#usage)

### ArrayHelper sort()

[](#arrayhelper-sort)

- Easily sort arrays based on properties or values in both ascending and descending order.

```
    use Berdidajohnlouise\ArrayHelper\ArrayHelper;

    /**
     * Method sorting arrays by associative or indexed array
     *
     * @param string $property => string | null
     * @param bool $isAscending  => true | false | default value => true
     *
     * @return array ascending || descending
     */

    // Sorting Indexed Arrays.
    $array = [5,3,1,4,2];
    $arrayHelper = new ArrayHelper($array);
    // Sort Ascending
    $sortedIndexArray = $arrayHelper->sort();
    // Output: [1,2,3,4,5]

    // Sort Descending
    $sortedIndexArray = $arrayHelper->sort(null,false);
    // Output: [5,4,3,2,1]

    // Sorting Via Associative Array
    $array = [
            ['name' => 'John', 'age' => 30],
            ['name' => 'Jane', 'age' => 25],
            ['name' => 'Bob', 'age' => 35],
        ];

    $arrayHelper = new ArrayHelper($array);

    // Sort Associative array order by ascending default
    $sortedArrayAsc = $arrayHelper->sort('age');
    // Output = [
    //        ['name' => 'Jane', 'age' => 25],
    //        ['name' => 'John', 'age' => 30],
    //        ['name' => 'Bob', 'age' => 35],
    // ]

    // Sort Associative array order by descending
    $sortedArrayAsc = $arrayHelper->sort('age',false);
    // Output = [
    //        ['name' => 'Bob', 'age' => 35],
    //        ['name' => 'John', 'age' => 30],
    //        ['name' => 'Jane', 'age' => 25],
    // ]
```

### Array merge()

[](#array-merge)

- Merge multiple arrays into a single array, combining their elements.

```
    use Berdidajohnlouise\ArrayHelper\ArrayHelper;
    /**
     * Method merge arrays helper function
     *
     * @param ...$arrays $arrays [can accept multiple param arrays]
     *
     * @return array
     */

    $array1 = ['name' => 'John', 'age' => 30];
    $array2 = ['city' => 'New York', 'country' => 'USA'];
    $array3 = ['occupation' => 'Developer'];

    // Without instantiating of array in constructor
    $arrayHelpers = new ArrayHelper;
    $mergedArray = $arrayHelpers->merge($array1, $array2, $array3);
    // Output = [
    //    'name' => 'John',
    //    'age' => 30,
    //    'city' => 'New York',
    //    'country' => 'USA',
    //    'occupation' => 'Developer',
    // ]

    // instantiating of array in constructor
    $arrayHelpers = new ArrayHelper($array1);
    $mergedArray = $arrayHelpers->merge($array2, $array3);
    // Output = [
    //    'name' => 'John',
    //    'age' => 30,
    //    'city' => 'New York',
    //    'country' => 'USA',
    //    'occupation' => 'Developer',
    // ]
```

### Array get()

[](#array-get)

- Retrieve values from arrays using keys or complex paths.

```
    use Berdidajohnlouise\ArrayHelper\ArrayHelper;
    /**
    * Method get for retrieving a value from an array using a dot-separated key or direct array key.
    *
    * @param string $key => dot separated or direct array key
    *
    * @return void
    */
    $array = ['user' => ['name' => 'Jane', 'email' => 'jane@example.com']];
    $arrayHelper = new ArrayHelper($array);
    $value = $arrayHelper->get('user.name');
    // Output: Jane
    OR
    $array = ['name' => 'John', 'age' => 30, 'city' => 'New York'];
    $arrayHelper = new ArrayHelper($array);
    $value = $arrayHelper->get('name');
    // Output: John
```

### Array has()

[](#array-has)

- Determine if an array contains a specific key or value.

```
    use Berdidajohnlouise\ArrayHelper\ArrayHelper;
    /**
    * Method has that checks an array if has a certain key.
    *
    * @param $key $key
    *
    * @return bool
    */

    $array = ['name' => 'John', 'age' => 30, 'city' => 'New York'];

    $arrayHelpers = new ArrayHelper($array);
    $arrayHelpers->has('name');
    // Output: True
    $arrayHelpers->has('gender');
    // Output: False
```

Contributing
------------

[](#contributing)

Contributions are welcome! If you find a bug or want to add new features, please submit an issue or a pull request on the GitHub repository.

Credits
-------

[](#credits)

ArrayHelper is developed and maintained by [Berdida John Louise](https://github.com/berdidajohnlouise)

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 Bus Factor1

Top contributor holds 75% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/53bbe2146a79c30d050521e46feff642d3c86d10eeb41bbec378f0ca7a67350a?d=identicon)[berdidajohnlouise](/maintainers/berdidajohnlouise)

---

Top Contributors

[![minato-berdida](https://avatars.githubusercontent.com/u/87978511?v=4)](https://github.com/minato-berdida "minato-berdida (6 commits)")[![berdidajohnlouise](https://avatars.githubusercontent.com/u/57049618?v=4)](https://github.com/berdidajohnlouise "berdidajohnlouise (2 commits)")

### Embed Badge

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

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

###  Alternatives

[ericmann/wp-session-manager

Prototype session management for WordPress.

27123.6k1](/packages/ericmann-wp-session-manager)[irazasyed/docgen

Streamline your Laravel package development with automatic facade documentation using Docgen for Laravel

233.8k10](/packages/irazasyed-docgen)

PHPackages © 2026

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