PHPackages                             pyrsmk/funktions - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. pyrsmk/funktions

AbandonedArchivedLibrary[File &amp; Storage](/categories/file-storage)

pyrsmk/funktions
================

Premium PHP functions with a salt of functional programming

3.2.1(4y ago)17423MITPHPPHP &gt;=7.4.0

Since Jan 28Pushed 4y ago1 watchersCompare

[ Source](https://github.com/pyrsmk/Funktions)[ Packagist](https://packagist.org/packages/pyrsmk/funktions)[ RSS](/packages/pyrsmk-funktions/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (39)Used By (3)

Funktions
=========

[](#funktions)

Funktions is a set of useful PHP functions aiming to ease your life by appending missing ones from PHP core, with a salt for functional programming. It has been heavily inspired by Ruby-ish API and augmented from real life needs from my professional use cases.

These functions are designed:

- to be immutables
- to support iterables, not only arrays
- to support all callables, not only closures
- to use generators first, because it rocks!

**WARNING!!! THIS LIBRARY IS STILL UNDER HEAVY DEVELOPMENT AND IS NOT TESTED YET**

Install
-------

[](#install)

```
composer require pyrsmk/funktions
```

Usage
-----

[](#usage)

```
use function Funktions\array_flatten;

$fruits = [
  ['strawberries', 'kiwis'],
  [
    ['oranges'],
    [
      ['lemons'],
      [
        'melons',
        ['raspberries']
      ]
    ]
  ]
];

$flatten_fruits = array_flatten($fruits);
```

### `array.php`

[](#arrayphp)

- `array_diff_strict (array $array1, array $array2) : array`: Strict diff between two arrays by comparing the values at the same index.
- `array_drop (array $array, int $offset, int $length) : array`: Drop a part of an array (immutable `array_splice`).
- `array_intersect_strict (array $array1, array $array2) : array`: Strict insersection between two arrays by comparing the values at the same index.
- `array_fill_multi (int $dimensions, int $size, mixed $value) : array`: Initialize multi-dimensional arrays.
- `array_flatten (array $array, ?int $min_depth = null) : array` : Flatten an array by keeping an arbitrary minimum depth if necessary.
- `array_merge_recursive_unique (array ...$arrays) : array`: Contrary to `array_merge_recursive()`, it merges array by replacing values of the same key instead of appending them into a new array.
- `array_seek (array &$array, int|string $key) : void`: Move the array pointer to a specified key (mutable).
- `array_substitute (array $array, int $offset, int $length, array $replacement) : array`: Improved `array_splice()` with full string keys support when replacing.
- `glue (array $array, string $glue = '') : string`: Glue array elements together, like `implode()` but with parameters in the right order.
- `immut_array_push (array $array, ...$elements) : array`: Immutable `array_push()`.
- `immut_array_shuffle (array $array) : array`: Immutable `shuffle()`.
- `immut_array_unset (array $array, int|string $key)`: Immutable `unset()`.
- `immut_array_unshift (array $array, ...$elements) : array`: Immutable `array_unshift()`.
- `immut_arsort (array $array, int $flags = SORT_REGULAR) : array`: Immutable `arsort()`.
- `immut_asort (array $array, int $flags = SORT_REGULAR) : array`: Immutable `asort()`.
- `immut_krsort (array $array, int $flags = SORT_REGULAR) : array`: Immutable `krsort()`.
- `immut_ksort (array $array, int $flags = SORT_REGULAR) : array`: Immutable `ksort()`.
- `immut_natcasesort (array $array) : array`: Immutable `natcasesort()`.
- `immut_natsort (array $array) : array`: Immutable `natsort()`.
- `immut_rsort (array $array, int $flags = SORT_REGULAR) : array`: Immutable `rsort()`.
- `immut_sort (array $array, int $flags = SORT_REGULAR) : array`: Immutable `sort()`.
- `immut_uasort (array $array, callable $compare) : array`: Immutable `uasort()`.
- `immut_uksort (array $array, callable $compare) : array`: Immutable `uksort()`.
- `immut_usort (array $array, callable $compare) : array`: Immutable `usort()`.
- `kmax (array $array) : mixed`: Return the key of the maximum value.
- `kmin (array $array) : mixed`: Return the key of the minimum value.

### `color.php`

[](#colorphp)

- `hex2rgb (string $hex) : array`: Convert HTML to RGB color.
- `hsl2rgb (int $h, int $s, int $l) : array`: Convert HSL to RGB color.
- `hsv2rgb (int $h, int $s, int $v) : array`: Convert HSV to RGB color.
- `rgb2hex (int $r, int $g, int $b) : string`: Convert RGB to HTML color.
- `rgb2hsl (int $r, int $g, int $b) : array`: Convert RGB to HSL color.
- `rgb2hsv (int $r, int $g, int $b) : array`: Convert RGB to HSV color.

### `iterable.php`

[](#iterablephp)

- `all (iterable $iterable, callable $callable) : bool`: Return `true` when all elements match the callable's condition.
- `any (iterable $iterable, callable $callable) : bool`: Return `true` when at least one element matches the callable's condition.
- `ensure_generator ($maybe_a_generator) : Generator`: Ensure that the passed value will be a generator.
- `enumerate (iterable $iterable, ?callable $callable = null) : int`: Enumerate elements in an iterable.
- `first (iterable $iterable) : mixed`: Return the first element of an iterable. Note that the iterable's pointer will be resetted.
- `iterable_to_generator (iterable $items) : Generator`: Convert an iterable to a generator.
- `itoa (Traversable $iterator, bool $use_keys = true) : array`: Alias to `iterator_to_array()`.
- `itog (iterable $items) : Generator`: Alias to `iterable_to_generator()`.
- `last (iterable $iterable) : mixed`: Return the last element of an iterable. Note that: if the iterable is an array, then its pointer will be resetted; if the iterable is not an array, it will be converted to one, then have in mind that a complete iteration will be done before being able to get its last element.
- `map (iterable $iterable, callable $callable) : Generator`: Like `array_map()` but works on any iterable and with key/value support.
- `none (iterable $iterable, callable $callable) : bool`: Return `true` when no element has matched the callable's condition.
- `pluck (iterable $iterable, string ...$keys) : Generator`: Extract lines from an iterable based on the requested keys.
- `reduce (iterable $iterable, callable $callable, $initial = null)`: Like `array_reduce()` but works on any iterable and with key/value support.
- `reject (iterable $iterable, callable $callable) : Generator`: Reject items that match the callable's condition.
- `select (iterable $iterable, callable $callable) : Generator`: Select items that match the callable's condition.
- `value (iterable $iterable, string $key) : mixed`: Retrieve a value from an iterable with a specified key. Note that it should be used with a hash or an array because iterating other an iterable for searching an element is not efficient at all.

### `instruction.php`

[](#instructionphp)

- `condition (bool $test, callable $truthy, callable $falsy) : mixed`: Return a value based on a test.
- `loop (iterable $iterable, callable $callable) : Generator`: Loop over an iterable and yield new values.
- `rescue (callable $callable, array $exceptions) : mixed`: Execute a callback and catch exceptions.

### `memory.php`

[](#memoryphp)

- `memory_safe (callable $callable) : mixed`: Collect garbage after callable execution.

### `number.php`

[](#numberphp)

- `above (float $value, float $min) : float`: Bound a number to a minimum value.
- `is_even (int $value) : bool`: Verify if the value is even.
- `is_odd (int $value) : bool`: Verify if the value is odd.
- `under (float $value, float $max) : float`: Bound a number to a maximum value.

### `output.php`

[](#outputphp)

- `capture (callable $callable) : string`: Capture output on a callable execution.
- `mute (callable $callable) : mixed`: Mute output on a callable execution.
- `puts (string $text) : void`: Print a one-line text.

### `regex.php`

[](#regexphp)

- `regex_count (string $pattern, string $text, int $flags = 0) : int`: Count the number of matches for a regex in a string.
- `regex_match (string $pattern, string $text, int $flags = 0) : Generator`: Return the matches of a regex, for the first match.
- `regex_match_all (string $pattern, string $text, int $flags = 0) : Generator`: Return all the matches of a regex.
- `regex_match_first (string $pattern, string $text, int $flags = 0) : string`: Return the first occurrence of the first match of a regex.
- `regex_test (string $pattern, string $text, int $flags = 0) : bool`: Test if a regex matches against a string.

### `string.php`

[](#stringphp)

- `mb_lcfirst ($string, string $encoding = null) : string`: Uncapitalize a string (multibyte support).
- `mb_to_camelcase (string $string) : string`: Converts a string to camelcase (multibyte support).
- `mb_truncate (string $string, int $length, string $encoding = null) : string`: Truncate a string to a specific length and append `...` at the end of the string (multibyte support).
- `mb_ucfirst (string $string, string $encoding = null) : string`: Capitalize a string (multibyte support).
- `mb_ucwords (string $string, string $encoding = null) : string`: Capitalize all words in a string (multibyte support).
- `random_hash (int $length = 5) : string`: Generate a random hash.
- `uuid_v4 () : string`: Generate a random v4 UUID.

### `system.php`

[](#systemphp)

- `human_fileperms (string $path) : string`: Get human-readable file permissions.
- `human_filesize (string $path) : string`: Get human-readable file size.
- `lessdir (string $dir) : array`: Like `scandir()` but without `.` and `..`.
- `mimetype (string $path) : string`: Get a file's mime type with several mecanism support.
- `rrmdir (string $path) : void`: Remove a directory recursively.

License
-------

[](#license)

MIT.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity75

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 ~70 days

Recently: every ~92 days

Total

38

Last Release

1586d ago

Major Versions

0.11.3 → 1.0.02019-08-31

1.1.0 → 2.0.02019-09-02

2.0.1 → v3.0.02021-02-25

PHP version history (4 changes)0.1.1PHP &gt;=5.3.0

0.2.0PHP &gt;=5.4.0

0.3.0PHP &gt;=7.2.0

v3.0.0PHP &gt;=7.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7f97d81cfd6d30587cdae24925bc0899331394d723d04ee4b76eb9435a565fe9?d=identicon)[pyrsmk](/maintainers/pyrsmk)

---

Top Contributors

[![pyrsmk](https://avatars.githubusercontent.com/u/214497?v=4)](https://github.com/pyrsmk "pyrsmk (23 commits)")

---

Tags

arraystringgeneratorcolorfilememoryregexmimetypesystemfunctionalprintechonumberoutputiterableinstruction

### Embed Badge

![Health badge](/badges/pyrsmk-funktions/health.svg)

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

###  Alternatives

[league/flysystem-memory

In-memory filesystem adapter for Flysystem.

8737.3M276](/packages/league-flysystem-memory)[adlawson/vfs

Virtual file system

300440.8k22](/packages/adlawson-vfs)[jstewmc/php-helpers

Static classes to help with numbers, strings, arrays, files, and bools in PHP

3111.6k2](/packages/jstewmc-php-helpers)[wikimedia/relpath

Work with file paths to join or find the relative path

13933.5k4](/packages/wikimedia-relpath)[riimu/kit-pathjoin

Cross-platform library for normalizing and joining file system paths

12672.0k6](/packages/riimu-kit-pathjoin)[samsonasik/array-lookup

A fast lookup library that help you verify and search array and Traversable data

2868.2k2](/packages/samsonasik-array-lookup)

PHPackages © 2026

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