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

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

dekor/php-array-table
=====================

PHP Library for printing associative arrays as text table (similar to mysql terminal console)

2.0(3y ago)296.6M—6.4%4[1 issues](https://github.com/deniskoronets/php-array-table/issues)[1 PRs](https://github.com/deniskoronets/php-array-table/pulls)1BSD-3-ClausePHPPHP &gt;=5.6.0CI passing

Since Oct 25Pushed 6mo ago3 watchersCompare

[ Source](https://github.com/deniskoronets/php-array-table)[ Packagist](https://packagist.org/packages/dekor/php-array-table)[ RSS](/packages/dekor-php-array-table/feed)WikiDiscussions master Synced 1mo ago

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

PHP Array To Text Table
=======================

[](#php-array-to-text-table)

[![packagist](https://camo.githubusercontent.com/f7897f7d5b5c41a939454c468bc9075eadfb103a3ea47c60b663215ea6789e45/68747470733a2f2f706f7365722e707567782e6f72672f64656b6f722f7068702d61727261792d7461626c652f76)](https://packagist.org/packages/dekor/php-array-table)[![downloads](https://camo.githubusercontent.com/79df14c2024ca902288a8c43f0f38473534a6bb36b91b3a6c8bce4d90aa2129d/68747470733a2f2f706f7365722e707567782e6f72672f64656b6f722f7068702d61727261792d7461626c652f646f776e6c6f616473)](https://packagist.org/packages/dekor/php-array-table)[![min php version](https://camo.githubusercontent.com/62cd111b8d915ce859d52db607de4c701fa3dc601ac1e2295d6a24bba496a8ec/68747470733a2f2f706f7365722e707567782e6f72672f64656b6f722f7068702d61727261792d7461626c652f726571756972652f706870)](https://packagist.org/packages/dekor/php-array-table)[![license](https://camo.githubusercontent.com/8ea8dd847cc085605237341f6b2979cc868d1a2515f2bd4f7208c0ba15d1eb16/68747470733a2f2f706f7365722e707567782e6f72672f64656b6f722f7068702d61727261792d7461626c652f6c6963656e7365)](https://packagist.org/packages/dekor/php-array-table)[![tests](https://github.com/deniskoronets/php-array-table/actions/workflows/tests.yml/badge.svg)](https://github.com/deniskoronets/php-array-table/actions/workflows/tests.yml)[![code coverage badge](https://raw.githubusercontent.com/deniskoronets/php-array-table/image-data/coverage.svg)](https://raw.githubusercontent.com/deniskoronets/php-array-table/image-data/coverage.svg)[![lines of code](https://raw.githubusercontent.com/deniskoronets/php-array-table/image-data/lines.svg)](https://raw.githubusercontent.com/deniskoronets/php-array-table/image-data/lines.svg)

PHP-class, which allows to transform php associative arrays to cool ASCII tables.

[![Blue](https://camo.githubusercontent.com/871bef4fc19db69395c3c5b2eb31e6123d3438aaa503e386355f515dc854c12a/68747470733a2f2f706c616365686f6c642e636f2f31357831352f3030354242422f3030354242422e706e67)](https://camo.githubusercontent.com/871bef4fc19db69395c3c5b2eb31e6123d3438aaa503e386355f515dc854c12a/68747470733a2f2f706c616365686f6c642e636f2f31357831352f3030354242422f3030354242422e706e67)[![Yellow](https://camo.githubusercontent.com/457573e5c61be47f41c75ff5f07cbe35511bef67a44836b1c1fb2aef56dd6a57/68747470733a2f2f706c616365686f6c642e636f2f31357831352f4646443530302f4646443530302e706e67)](https://camo.githubusercontent.com/457573e5c61be47f41c75ff5f07cbe35511bef67a44836b1c1fb2aef56dd6a57/68747470733a2f2f706c616365686f6c642e636f2f31357831352f4646443530302f4646443530302e706e67) [Ukraine ❤](https://woo.zp.ua/en/support-ukraine/)

Quick doc:
==========

[](#quick-doc)

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

[](#installation)

Simply run composer require:

```
composer require dekor/php-array-table
```

or add to composer.json:

```
"dekor/php-array-table": "^2.0"
```

Usage
-----

[](#usage)

```
use dekor\ArrayToTextTable;

$data = [
    [
        'id' => 1,
        'name' => 'Denis Koronets',
        'role' => 'php developer',
    ],
    [
        'id' => 2,
        'name' => 'Maxim Ambroskin',
        'role' => 'java developer',
    ],
    [
        'id' => 3,
        'name' => 'Andrew Sikorsky',
        'role' => 'php developer',
    ]
];

echo (new ArrayToTextTable($data))->render();
```

Will draw the next output:

```
+----+-----------------+----------------+
| id | name            | role           |
+----+-----------------+----------------+
| 1  | Denis Koronets  | php developer  |
| 2  | Maxim Ambroskin | java developer |
| 3  | Andrew Sikorsky | php developer  |
+----+-----------------+----------------+
```

Formatters (since v2)
---------------------

[](#formatters-since-v2)

Version 2 introduces a new feature that allows to pre and postprocess column data by applying filters.

You're able to develop your own formatters by extending `BaseColumnFormatter` and implementing abstract methods.

List of formatters out of the box:

- `AlignFormatter` - allows to set text align for inner column (useful for numbers):

```
use dekor\ArrayToTextTable;
use dekor\formatters\AlignFormatter;

$data = [
    [
        'left' => 2,
        'center' => 'Dummy one',
        'right' => 14.33,
    ],
    [
        'left' => 3,
        'center' => 'Another great day for a great inventers!',
        'right' => 1,
    ],
];

$builder = new ArrayToTextTable($data);
$builder->applyFormatter(new AlignFormatter(['center' => 'center', 'right' => 'right']));

echo $builder->render();
```

outputs:

```
+------+------------------------------------------+-------+
| left | center                                   | right |
+------+------------------------------------------+-------+
| 2    |                Dummy one                 | 14.33 |
| 3    | Another great day for a great inventers! |     1 |
+------+------------------------------------------+-------+
```

- `SprintfFormatter` - allows to format column value before rendering using sprintf function (ex: %01.3f)

```
use dekor\ArrayToTextTable;
use dekor\formatters\SprintfFormatter;

$data = [
    [
        'left' => 1,
        'right' => 2.89,
    ]
];

$builder = new ArrayToTextTable($data);
$builder->applyFormatter(new SprintfFormatter(['left' => '%01.3f', 'right' => '%03.3f']));

echo $builder->render();
```

outputs:

```
+-------+-------+
| left  | right |
+-------+-------+
| 1.000 | 2.890 |
+-------+-------+
```

- `ColorFormatter` - allows to highlight text with specific color (only works in terminal):

```
use dekor\ArrayToTextTable;
use dekor\formatters\ColorFormatter;

$data = [
    ['test' => 1],
    ['test' => -1],
];

$builder = new ArrayToTextTable($data);
$builder->applyFormatter(new ColorFormatter(['test' => fn ($value) => $value > 0 ? 'Red' : 'Green']));

echo $builder->render() . PHP_EOL;
```

outputs:

[![img.png](img.png)](img.png)

Allowed colors list (see `ColorFormatter::$colors`)

- Black
- Dark Grey
- Red
- Light Red
- Green
- Light Green
- Brown
- Yellow
- Blue
- Light Blue
- Magenta
- Light Magenta
- Cyan
- Light Cyan
- Light Grey
- White

Our sponsors list:
------------------

[](#our-sponsors-list)

[![](https://camo.githubusercontent.com/01b08b2e1d57164c990316f1355c48484506b7866864d1c52a387c27bb8bf031/68747470733a2f2f6d6f6269636172642e636f6d2e75612f66617669636f6e2e737667)](https://mobicard.com.ua/)[![](https://camo.githubusercontent.com/445dea303e159de2da5589a1903d06038a334974c8fad109594119550896de85/68747470733a2f2f62757379622e636f6d2e75612f66617669636f6e2e737667)](https://busyb.com.ua/)[![](https://camo.githubusercontent.com/7ec054e2160836a9265f36fa5dfb26989aa0775a8d434c7e3644b1e9aea4cca0/68747470733a2f2f776f6f2e7a702e75612f77702d636f6e74656e742f75706c6f6164732f323032342f30322f63726f707065642d576f6f2d313932783139322e706e67)](https://woo.zp.ua/)[![](https://camo.githubusercontent.com/65a9993b2601579a485e4ef03d2cde15d3bf51cdb9ceaddd4225545430e372f8/68747470733a2f2f70632d696e666f2e636f6d2e75612f66617669636f6e2e737667)](https://pc-info.com.ua/)[![](https://camo.githubusercontent.com/fba2ada9fc2452afa664b0cba301972647e5437d8d689a1e31cd78768755743d/68747470733a2f2f6c696e6b74727573742e70726f2f6c696e6b74727573742e737667)](https://linktrust.pro/)

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance47

Moderate activity, may be stable

Popularity55

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 58.9% 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 ~1933 days

Total

2

Last Release

1193d ago

Major Versions

1.0 → 2.02023-02-10

PHP version history (2 changes)1.0PHP &gt;=5.4.0

2.0PHP &gt;=5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/86a454ce259bed93b03b53cd47433d29ea342926a4005ddbed2ea33aa0143d54?d=identicon)[deniskoronets](/maintainers/deniskoronets)

---

Top Contributors

[![deniskoronets](https://avatars.githubusercontent.com/u/5627329?v=4)](https://github.com/deniskoronets "deniskoronets (33 commits)")[![8ctopus](https://avatars.githubusercontent.com/u/13252042?v=4)](https://github.com/8ctopus "8ctopus (15 commits)")[![Insolita](https://avatars.githubusercontent.com/u/1847402?v=4)](https://github.com/Insolita "Insolita (7 commits)")[![loekvangool](https://avatars.githubusercontent.com/u/7300472?v=4)](https://github.com/loekvangool "loekvangool (1 commits)")

---

Tags

phplibrary

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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