PHPackages                             infrajs/each - 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. infrajs/each

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

infrajs/each
============

v1.0.7(6y ago)02.8k13PHP

Since Jan 22Pushed 5y ago1 watchersCompare

[ Source](https://github.com/infrajs/each)[ Packagist](https://packagist.org/packages/infrajs/each)[ Docs](https://github.com/infrajs/each)[ RSS](/packages/infrajs-each/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (6)DependenciesVersions (9)Used By (13)

[![Latest Stable Version](https://camo.githubusercontent.com/3c0d79e05edf7a6749308fa2b75a87cf2063b6d7c5f398045dcb3ded9cb8025f/68747470733a2f2f706f7365722e707567782e6f72672f696e6672616a732f656163682f762f737461626c65)](https://packagist.org/packages/infrajs/each) [![Total Downloads](https://camo.githubusercontent.com/eb70f717f2c75d6de6db06a592d0d081cea67682c3f387c70cc12492077f9940/68747470733a2f2f706f7365722e707567782e6f72672f696e6672616a732f656163682f646f776e6c6f616473)](https://packagist.org/packages/infrajs/each)

### Each::exec - Collback for each element of array or for simple value.

[](#eachexec---collback-for-each-element-of-array-or-for-simple-value)

> The function processes the transmitted data as if it were an indexed array of unit length; If you really gave an indexed array, then an anonymous function run for each element of the index array; If you gave any type except an index array, the data is processed as an indexed array with one element and passed to the anonymous function will run for one item. For an element with a null value the function will not run.

```
$counter = 0;
$el = [2, [4, 6], 5];
Each::exec($el, function ($b) use (&$counter) {
    $counter++;
    if ($counter === 3) {
        assert(6 === $b);
    }
});

```

### Each::isAssoc - this method checks whether the passed argument is an associative array.

[](#eachisassoc---this-method-checks-whether-the-passed-argument-is-an-associative-array)

```
$elements = ['9' => '42', 8, 4, 5, 3];
assert(true === Each::isAssoc($elements));
$elements = [9, 8, 4, 5, 3];
assert(false === Each::isAssoc($elements));

```

### Each::isInt - this method checks the passed argument is a number.

[](#eachisint---this-method-checks-the-passed-argument-is-a-number)

> If the passed text argument in the form of a number (without spaces or additional text), then the method will work with parameters such as the number.

```
$el = 12;
assert(true === Each::isInt($el));
$el = '12';
assert(true === Each::isInt($el));

```

### Each::isEqual - this method checks whether the passed arguments by reference.

[](#eachisequal---this-method-checks-whether-the-passed-arguments-by-reference)

> The method returns true only when the two variables are references to each other.

```
$a = 1;
$b = &$a;
assert(true === Each::isEqual($a, $b));

```

### Testing

[](#testing)

##### Testing run the file test.php:

[](#testing-run-the-file-testphp)

> positive answer

```
{result:1}

```

> negative answer

```
{"result":0, msg:"В работе кода произошел сбой."}

```

##### Testing with PHPunit

[](#testing-with-phpunit)

```
phpunit --bootstrap Each.php tests/EachTest

```

### Each::exec - callback-функция для каждого элемента индексного массива или для простого значения.

[](#eachexec---callback-функция-для-каждого-элемента-индексного-массива-или-для-простого-значения)

> Функция обрабатывает переданные данные, как будто они переданы в индексном массиве единичной длины; Если действительно передан индексный массив, то анонимная фукцния сработает для каждого элемента индексного массива; Если передан любой тип, кроме индексного массива, то данные обработаются как индексный массив с одним переданным элементом и анонимная функция запустится для одного элемента. Для элемента со значением null функция запускаться не будет.

```
$counter = 0;
$el = [2, [4, 6], 5];
Each::exec($el, function ($b) use (&$counter) {
    $counter++;
    if ($counter === 3) {
        assert(6 === $b);
    }
});

```

### Each::isAssoc - данный метод проверяет, является ли переданный аргумент ассоциативным массивом.

[](#eachisassoc---данный-метод-проверяет-является-ли-переданный-аргумент-ассоциативным-массивом)

```
$elements = ['9' => '42', 8, 4, 5, 3];
assert(true === Each::isAssoc($elements));
$elements = [9, 8, 4, 5, 3];
assert(false === Each::isAssoc($elements));

```

### Each::isInt - данный метод проверяет, является переданный аргумент числом.

[](#eachisint---данный-метод-проверяет-является-переданный-аргумент-числом)

> Если передан текстовый аргумент в виде числа (без пробелов и дополнительного текста), то метод отработает с таким параметром, как с числом.

```
$el = 12;
assert(true === Each::isInt($el));
$el = '12';
assert(true === Each::isInt($el));

```

### Each::isEqual - данный метод проверяет, являются ли переданные аргументы ссылками.

[](#eachisequal---данный-метод-проверяет-являются-ли-переданные-аргументы-ссылками)

> Метод возвращает true, только когда две переменные являются ссылками друг на друга.

```
$a = 1;
$b = &$a;
assert(true === Each::isEqual($a, $b));

```

### Тест

[](#тест)

##### Для тестирования откройте в браузере test.php:

[](#для-тестирования-откройте-в-браузере-testphp)

> при положительном ответе вы увидете следующее сообщение

```
{"result":1}

```

> если в работе кода произойдет сбой, то сообщение будет

```
{"result":0, msg:"В работе кода произошел сбой."}

```

##### Для тестирование с помощью PHPunit

[](#для-тестирование-с-помощью-phpunit)

```
phpunit --bootstrap Each.php tests/EachTest

```

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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 ~224 days

Recently: every ~362 days

Total

8

Last Release

2236d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/341a8ef8a06866ad99b1bbcf0216fd8e331b076b1690a7d992c386192674b787?d=identicon)[akiyatkin](/maintainers/akiyatkin)

---

Top Contributors

[![akiyatkin](https://avatars.githubusercontent.com/u/953753?v=4)](https://github.com/akiyatkin "akiyatkin (14 commits)")[![oduvanio](https://avatars.githubusercontent.com/u/11479446?v=4)](https://github.com/oduvanio "oduvanio (7 commits)")

### Embed Badge

![Health badge](/badges/infrajs-each/health.svg)

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

###  Alternatives

[imanghafoori/laravel-temp-tag

Laravel Temporary Tag simplify tagging Eloquent models.

1018.6k](/packages/imanghafoori-laravel-temp-tag)

PHPackages © 2026

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