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

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

buddhika/helpers
================

A set of useful helpers

00PHP

Since May 10Pushed 3y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Helpers
=======

[](#helpers)

- [Installation](#installation)
- [Usage](#usage)
    - [Flatten array](#flatten-array)
    - [Sort array by key (values)](#sort-array-by-key-values)
    - [Detect languages](#detect-languages)
    - [Get a random element](#get-a-random-element)
    - [Slugify strings](#slugify-strings)

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

[](#installation)

```
composer require buddhika/helpers

```

Usage
-----

[](#usage)

```
namespace Buddhika\Helpers;
```

### Flatten array

[](#flatten-array)

```
$array = array(['a'], ['b', 'c'], ['d', 'e', 'f']);
$flattenedArray = Helpers::arrayFlatten($array);

print_r($flattenedArray);

/*
Array
(
    [0] => a
    [1] => b
    [2] => c
    [3] => d
    [4] => e
    [5] => f
)
*/
```

### Sort array by key (values)

[](#sort-array-by-key-values)

```
$array = array(
    array("name" => "John", "age" => 23),
    array("name" => "Jane", "age" => 21),
    array("name" => "Mike", "age" => 25)
);
$sortedArray = Helpers::arraySortByKey($array, "age");

print_r($sortedArray);

/*
Array
(
    [0] => Array
        (
            [name] => Jane
            [age] => 21
        )

    [1] => Array
        (
            [name] => John
            [age] => 23
        )

    [2] => Array
        (
            [name] => Mike
            [age] => 25
        )

)
*/
```

### Detect languages

[](#detect-languages)

```
$languageModels = [
    'en' => ['hello', 'world', 'goodbye'],
    'es' => ['hola', 'mundo', 'adios'],
    'fr' => ['bonjour', 'monde', 'au revoir'],
];
$text = 'Hello world! How are you doing today?';
$result = Helpers::languageScores($languageModels, $text);

print_r($result);

/*
Array
(
    [en] => 1.0
    [es] => 0.0
    [fr] => 0.0
)
*/
```

### Get a random element

[](#get-a-random-element)

```
$array = ['apple', 'banana', 'cherry'];
$element = Helpers::randomElement($array);

print_r($element);

// banana
```

### Slugify strings

[](#slugify-strings)

```
$text = "Commit Often, Perfect Later, Publish Once: Git Best Practices";
$result = Helpers::slugify($text);

print_r($result);

// commit-often-perfect-later-publish-once-git-best-practices
```

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity22

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

[![lsnt4](https://avatars.githubusercontent.com/u/2859796?v=4)](https://github.com/lsnt4 "lsnt4 (8 commits)")

---

Tags

helper-functionshelpersphpwip

### Embed Badge

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

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

PHPackages © 2026

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