PHPackages                             gbhorwood/tabletown - 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. gbhorwood/tabletown

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

gbhorwood/tabletown
===================

A table output formatting utility for arrays

1.0.0(2y ago)4511MITPHPPHP ^8.1

Since Dec 19Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/gbhorwood/Tabletown)[ Packagist](https://packagist.org/packages/gbhorwood/tabletown)[ RSS](/packages/gbhorwood-tabletown/feed)WikiDiscussions main Synced yesterday

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

Tabletown
=========

[](#tabletown)

[![License](https://camo.githubusercontent.com/273dd22e09f2a51af3a63e570fd9f11f60aba5e16309c800868c57c235ab47a0/687474703a2f2f706f7365722e707567782e6f72672f6762686f72776f6f642f7461626c65746f776e2f6c6963656e7365)](https://packagist.org/packages/gbhorwood/tabletown)[![Version](https://camo.githubusercontent.com/63ac1d149ca9694f35bff509ea6dea02085cde4aa9e8fd3196afc332d480cda6/687474703a2f2f706f7365722e707567782e6f72672f6762686f72776f6f642f7461626c65746f776e2f76657273696f6e)](https://packagist.org/packages/gbhorwood/tabletown)[![PHP Version Require](https://camo.githubusercontent.com/3439557009965836c9aab30ceec983f0e49eccba42e30b27a93f3109efe73218/687474703a2f2f706f7365722e707567782e6f72672f6762686f72776f6f642f7461626c65746f776e2f726571756972652f706870)](https://packagist.org/packages/gbhorwood/tabletown)

Tabletown is a php package for converting data, such as arrays, into nice ascii/ansi tables, similar to MySql's standard output.

Tabletown can accept input from arrays, PDO statements, and eloquent collections. It properly handles multibyte characters, including emojis, as well as unprintable ansi character sequences and tabs. It allows setting per-column alignment and offers a number of border style options.

Tabletown was developed as an internal-use tool for [fruitbat studios](https://fruitbat.studio)/cloverhitch technologies/kludgetastic implementations.

Install
-------

[](#install)

Tabletown is installed via composer:

```
composer require gbhorwood/tabletown
```

Features
--------

[](#features)

Tabletown's basic features are:

- **Multiple input types:** Input can be arrays, `PDOStatement` objects or Eloquent collections.
- **Border styling:** Broders can be set as either solid lined, double solid lined or standard, MySql-style.
- **Per-column alignment:** Individual columns can be aligned left, right, or centre.
- **Multi-line rows** Line breaks in data are preseved and presented as multi-line rows.
- **Unicode-safe:** Multi-byte characters are handled.
- **Tab-safe:** Tab characters are handled with proper tab stops.
- **(mostly) ANSI-safe:** Most ansi escape codes, including backspace, are handled.

Quickstart
----------

[](#quickstart)

Tabletown has one static method `get()`. The fastest way to create and print a table is to provide the `get()` method with two arguments: an array of headers, and an array of data for table rows.

```
