dekor/php-array-table

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

1.0 2017-10-25 10:49 UTC

This package is auto-updated.

Last update: 2021-11-11 22:45:28 UTC


README

Scrutinizer Code Quality Build Status

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

Installation

Simply run composer require:

composer require dekor/php-array-table

or add to composer.json:

"dekor/php-array-table": "1.0"

Usage

<?php

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  |
+----+-----------------+----------------+

Made with ❤ by denis