PHPackages                             traderinteractive/filter-arrays - 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. traderinteractive/filter-arrays

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

traderinteractive/filter-arrays
===============================

A filtering implementation for verifying correct data and performing typical modifications to arrays

v4.1.0(2y ago)1103.4k↓48.8%32MITPHPPHP ^7.3 || ^8.0CI failing

Since Mar 6Pushed 2y ago7 watchersCompare

[ Source](https://github.com/traderinteractive/filter-arrays-php)[ Packagist](https://packagist.org/packages/traderinteractive/filter-arrays)[ RSS](/packages/traderinteractive-filter-arrays/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (6)Dependencies (3)Versions (7)Used By (2)

TraderInteractive Filter\\Arrays
================================

[](#traderinteractive-filterarrays)

[![Build Status](https://camo.githubusercontent.com/a47db814f6574d20b03f5ee823e9f682074e0ad5d668e3da2ba38e7518a7f09f/68747470733a2f2f7472617669732d63692e6f72672f747261646572696e7465726163746976652f66696c7465722d6172726179732d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/traderinteractive/filter-arrays-php)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/67a0c6cd417a7a808b168c50d180dfa25cfbf43c281ddd888f5ce7f95b0fb8c6/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f747261646572696e7465726163746976652f66696c7465722d6172726179732d7068702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/traderinteractive/filter-arrays-php/?branch=master)[![Coverage Status](https://camo.githubusercontent.com/fd7a617a980e653c65d4efed094dbab6d5f1e29fce925769ff0e41518959b4ba/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f747261646572696e7465726163746976652f66696c7465722d6172726179732d7068702f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/traderinteractive/filter-arrays-php?branch=master)

[![Latest Stable Version](https://camo.githubusercontent.com/5130ca2524ff42ba7d50c0e6f493778770290b8086f5a0d54d6e9f8ce289db06/68747470733a2f2f706f7365722e707567782e6f72672f747261646572696e7465726163746976652f66696c7465722d6172726179732f762f737461626c65)](https://packagist.org/packages/traderinteractive/filter-arrays)[![Latest Unstable Version](https://camo.githubusercontent.com/53664404b1505bf84a5064485d3c0b55c4ac24d3eaa13b8b08d6df0a6392b5ae/68747470733a2f2f706f7365722e707567782e6f72672f747261646572696e7465726163746976652f66696c7465722d6172726179732f762f756e737461626c65)](https://packagist.org/packages/traderinteractive/filter-arrays)[![License](https://camo.githubusercontent.com/5ac9e2fbfe006c7a0813bce904fb4ca3fa74b70ca64e54528182852f3d3351aa/68747470733a2f2f706f7365722e707567782e6f72672f747261646572696e7465726163746976652f66696c7465722d6172726179732f6c6963656e7365)](https://packagist.org/packages/traderinteractive/filter-arrays)

[![Total Downloads](https://camo.githubusercontent.com/633214bb695c94a388db616d1e136a3e98098fe417d343e9e797959d3f7366c4/68747470733a2f2f706f7365722e707567782e6f72672f747261646572696e7465726163746976652f66696c7465722d6172726179732f646f776e6c6f616473)](https://packagist.org/packages/traderinteractive/filter-arrays)[![Daily Downloads](https://camo.githubusercontent.com/529c24898d3cc66cd818a4b12889f1729df48a4073622cb8e9d3100fbe41b547/68747470733a2f2f706f7365722e707567782e6f72672f747261646572696e7465726163746976652f66696c7465722d6172726179732f642f6461696c79)](https://packagist.org/packages/traderinteractive/filter-arrays)[![Monthly Downloads](https://camo.githubusercontent.com/f9fe894190ec9e8e02c4170e7b477011a6e522612ed84430d9c314f13e115a81/68747470733a2f2f706f7365722e707567782e6f72672f747261646572696e7465726163746976652f66696c7465722d6172726179732f642f6d6f6e74686c79)](https://packagist.org/packages/traderinteractive/filter-arrays)

A filtering implementation for verifying correct data and performing typical modifications to arrays

Requirements
------------

[](#requirements)

Requires PHP 7.0 or newer and uses composer to install further PHP dependencies. See the [composer specification](composer.json) for more details.

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

[](#installation)

filter-arrays-php can be installed for use in your project using [composer](http://getcomposer.org). The recommended way of using this library in your project is to add a `composer.json` file to your project. The following contents would add filter-arrays-php as a dependency:

```
composer require traderinteractive/filter-arrays
```

Included Filters
----------------

[](#included-filters)

#### Arrays::copy

[](#arrayscopy)

This filter will copy values from the input array into the resulting array using the destination key map.

```
$input = ['foo' => 1, 'bar' => 2];
$keyMap = ['FOO_VALUE' => 'foo', 'BAR_VALUE' => 'bar'];
$result = \TraderInteractive\Filter\Arrays::copy($input, $keyMap);
assert($result === ['FOO_VALUE' => 1, 'BAR_VALUE' => 2]);
```

#### Arrays::copyEach

[](#arrayscopyeach)

This filter will copy values from each array within the input array into the resulting array using the destination key map.

```
$input = [
    ['foo' => 1, 'bar' => 2],
    ['foo' => 3, 'bar' => 4],
];
$keyMap = ['FOO_VALUE' => 'foo', 'BAR_VALUE' => 'bar'];
$result = \TraderInteractive\Filter\Arrays::copyEach($input, $keyMap);
assert($result === [['FOO_VALUE' => 1, 'BAR_VALUE' => 2], ['FOO_VALUE' => 3, 'BAR_VALUE' => 4]]);
```

#### Arrays::in

[](#arraysin)

This filter is a wrapper around `in_array` including support for strict equality testing.

The following does a strict check for `$value` against the 3 accepted values.

```
\TraderInteractive\Filter\Arrays::in($value, ['a', 'b', 'c']);
```

#### Arrays::filter

[](#arraysfilter)

This filter verifies that the argument is an array and checks the length of the array against bounds. The default bounds are 1+, so an empty array fails by default.

The following checks that the `$value` is an array with exactly 3 elements.

```
\TraderInteractive\Filter\Arrays::filter($value, 3, 3);
```

#### Arrays::flatten

[](#arraysflatten)

This filter flattens a multi-dimensional array to a single dimension. The order of values will be maintained, but the keys themselves will not. For example:

```
$value = \TraderInteractive\Filter\Arrays::flatten([[1, 2], [3, [4, 5]]]);
assert($value === [1, 2, 3, 4, 5]);
```

#### Arrays::implode

[](#arraysimplode)

This filter is a wrapper to the PHP `implode` function. It joins an array of strings with the optional glue string.

```
$value = \TraderInteractive\Filter\Arrays::implode(['lastname', 'email', 'phone'], ',');
assert($value === 'lastname,email,phone');
```

#### Arrays::pad

[](#arrayspad)

This filter pads an array to the specified length with a value. Padding optionally to the front or end of the array.

```
$value = \TraderInteractive\Filter\Arrays::pad([1, 2], 5, 0, \TraderInteractive\Filter\Arrays::ARRAY_PAD_FRONT);
assert($value === [0, 0, 0, 1, 2]);
```

#### Arrays::unique

[](#arraysunique)

This filter removes any duplicate values in the given array. Optionally throwing an exception if duplicate values are found.

```
$value = \TraderInteractive\Filter\Arrays::unique(['foo', 'bar', 'foo']);
assert($value === ['foo', 'bar']);
```

Project Build
-------------

[](#project-build)

With a checkout of the code get [Composer](http://getcomposer.org) in your PATH and run: ``sh composer install ./vendor/bin/phpunit ./vendor/bin/phpcs

```
For more information on our build process, read through out our [Contribution Guidelines](./.github/CONTRIBUTING.md).

```

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 81.8% 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 ~425 days

Recently: every ~453 days

Total

6

Last Release

912d ago

Major Versions

v3.3.0 → v4.0.02022-09-27

PHP version history (2 changes)v3.0.0PHP ^7.0

v4.0.0PHP ^7.3 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/29952359?v=4)[Trader Interactive](/maintainers/traderinteractive)[@traderinteractive](https://github.com/traderinteractive)

---

Top Contributors

[![chadicus](https://avatars.githubusercontent.com/u/1182337?v=4)](https://github.com/chadicus "chadicus (27 commits)")[![chrisryan](https://avatars.githubusercontent.com/u/704326?v=4)](https://github.com/chrisryan "chrisryan (4 commits)")[![jncarver](https://avatars.githubusercontent.com/u/6580693?v=4)](https://github.com/jncarver "jncarver (2 commits)")

---

Tags

arrayutilityfilter

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/traderinteractive-filter-arrays/health.svg)

```
[![Health](https://phpackages.com/badges/traderinteractive-filter-arrays/health.svg)](https://phpackages.com/packages/traderinteractive-filter-arrays)
```

###  Alternatives

[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k430.4M1.7k](/packages/nette-utils)[voku/arrayy

Array manipulation library for PHP, called Arrayy!

4915.7M18](/packages/voku-arrayy)[bocharsky-bw/arrayzy

A native PHP arrays easy manipulation library in OOP way.

38427.7k](/packages/bocharsky-bw-arrayzy)[flow-php/array-dot

PHP ETL - Array Dot functions

14514.6k6](/packages/flow-php-array-dot)[graze/data-structure

Data collections and containers

12295.9k10](/packages/graze-data-structure)[brunoconte3/dev-utils

A complete PHP utility library for validating, formatting, comparing data, and more.

4026.6k](/packages/brunoconte3-dev-utils)

PHPackages © 2026

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