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

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

hugsbrugs/php-array
===================

PHP Array Utilities

0.1(9y ago)043PHP

Since Mar 13Pushed 9y ago1 watchersCompare

[ Source](https://github.com/hugsbrugs/php-array)[ Packagist](https://packagist.org/packages/hugsbrugs/php-array)[ RSS](/packages/hugsbrugs-php-array/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

php-array
=========

[](#php-array)

This librairy provides utilities function to ease array manipulation

[![Build Status](https://camo.githubusercontent.com/e40109cce7a798e4b2feb447e27f72cad83ea9d418942a387aca0f79ddebfcb1/68747470733a2f2f7472617669732d63692e6f72672f6875677362727567732f7068702d61727261792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/hugsbrugs/php-array)[![Coverage Status](https://camo.githubusercontent.com/7a4e9956f5f1b9abdf9407271a4c3241fc965fae68340ce0a7256a0a1e0b3d49/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6875677362727567732f7068702d61727261792f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/hugsbrugs/php-array?branch=master)

Install
-------

[](#install)

Install package with composer

```
composer require hugsbrugs/php-array

```

In your PHP code, load library

```
require_once __DIR__ . '/../vendor/autoload.php';
use Hug\HArray\HArray as HArray;
```

Note: I couldn't use Array as namespace because it's a PHP reserved word so it's why namespace is HArray ...

Usage
-----

[](#usage)

Shuffle an array while preserving keys

```
HArray::shuffle_assoc(&$array);
```

Sort an array based on column filter and optional sort direction

```
HArray::array_sort_by_column(&$arr, $col, $dir = SORT_ASC);
```

Sort a 2 dimensional array based on 1 or more indexes.

```
$new_array = HArray::msort($array, $key, $sort_flags = SORT_REGULAR);
```

Recursively implodes an array with optional key inclusion

```
$string = HArray::recursive_implode($glue, array $array, $include_keys = false, $trim_all = true);
```

Transforms an object (and object of object) into an array

```
$new_array = HArray::object_to_array($obj);
```

Count in 2 dimensions arrays, number of rows in sub arrays

```
$count = HArray::sub_count($array);
```

Cuts a string into an array of strings depending of word count

```
$new_array = HArray::string_to_array($text, $word_count);
```

Inserts an element at a given position in an array

```
$array = ['pomme', 'poire', 'fraise', 'banane'];
$array = HArray::array_insert($array, 'kiwi', 2);
Array
(
    [0] => pomme
    [1] => poire
    [2] => kiwi
    [3] => fraise
    [4] => banane
)

$array = ['pomme', 'poire', 'fraise', 'banane'];
$array = HArray::array_insert($array, ['kiwi', 'mangue'], 2);
Array
(
    [0] => pomme
    [1] => poire
    [2] => kiwi
    [3] => mangue
    [4] => fraise
    [5] => banane
)
```

Unit Tests
----------

[](#unit-tests)

```
composer exec phpunit

```

Author
------

[](#author)

Hugo Maugey [visit my website ;)](https://hugo.maugey.fr)

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

3397d ago

### Community

Maintainers

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

---

Top Contributors

[![hugsbrugs](https://avatars.githubusercontent.com/u/4385090?v=4)](https://github.com/hugsbrugs "hugsbrugs (2 commits)")

---

Tags

arrayphpphp-array

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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