PHPackages                             kabachello/phptexttable - 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. kabachello/phptexttable

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

kabachello/phptexttable
=======================

Easily convert PHP arrays into plain text tables or strings with a fixed field length for each column

0.2.2(9y ago)4611MITPHP

Since Nov 14Pushed 8y ago2 watchersCompare

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

READMEChangelogDependenciesVersions (5)Used By (0)

phpTextTable
============

[](#phptexttable)

Easily converts PHP arrays into plain text tables, CSV files or strings with a fixed field length for each column

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

[](#installation)

```
composer require kabachello/phptexttable:*

```

Quick start
-----------

[](#quick-start)

```
error_reporting(E_ALL & ~E_NOTICE);

$rows = array(
		array('City' => 'Berlin', 'State' => 'Berlin', 'Pop. 1950' => 3336026, 'Pop. 2015' => 3520031),
		array('City' => 'Hamburg', 'State' => 'Hamburg', 'Pop. 1950' => 1605606, 'Pop. 2015' => 1787408),
		array('City' => 'Munich', 'State' => 'Bavaria', 'Pop. 1950' => 831937, 'Pop. 2015' => 1450381),
		array('city' => 'Cologne', 'State' => 'North Rhine-Westphalia', 'Pop. 1950' => 594941, 'Pop. 2015' => 1060582)
);

// Initialize the table
$text_table = new kabachello\phpTextTable\TextTable($rows);

// Set right alignment for the numeric columns
$text_table->setColumnAlignments(array('Pop. 1950' => 'right', 'Pop. 2015' => 'right'));

// Set the numer columns to the same fixed with
$text_table->setColumnWidthMax(array('Pop. 1950' => 11, 'Pop. 2015' => 11));

// Disable automatic width adjustment (only affects columns with max width)
$text_table->setColumnWidthAuto(false);

// Print the table
print $text_table->print($row_key);
```

will print the following:

```
+---------+------------------------+-------------+-------------+
|  CITY   |         STATE          |  POP. 1950  |  POP. 2015  |
+---------+------------------------+-------------+-------------+
| Berlin  | Berlin                 |     3336026 |     3520031 |
| Hamburg | Hamburg                |     1605606 |     1787408 |
| Munich  | Bavaria                |      831937 |     1450381 |
| Cologne | North Rhine-Westphalia |      594941 |     1060582 |
+---------+------------------------+-------------+-------------+

```

Credits
-------

[](#credits)

This library was inspired by [ArrayToTextTable](https://gist.github.com/tony-landis/31477)

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

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

Total

4

Last Release

3405d ago

### Community

Maintainers

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

### Embed Badge

![Health badge](/badges/kabachello-phptexttable/health.svg)

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

###  Alternatives

[trafficcophp/bytebuffer

Node.js inspired byte stream buffer for PHP.

33463.7k18](/packages/trafficcophp-bytebuffer)[synolia/sylius-gdpr-plugin

Synolia sylius GDPR plugin.

21156.4k](/packages/synolia-sylius-gdpr-plugin)[latuconsinafr/3d-bin-packager

PHP Library for 3D Bin Packing.

2865.8k](/packages/latuconsinafr-3d-bin-packager)

PHPackages © 2026

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