fgendorf/php-array-table

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

v1.0.1 2022-08-17 16:28 UTC

This package is not auto-updated.

Last update: 2024-05-23 22:55:43 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 fgendorf/php-array-table

or add to composer.json:

"fgendorf/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, compliance with markdown:

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

Made with ❤ by denis