2017 © Pedro Peláez
 

library array-to-text-php

This PHP class can convert an array into ascii text formatted table

image

imtiazmahbub/array-to-text-php

This PHP class can convert an array into ascii text formatted table

  • Friday, November 17, 2017
  • by imtiazmahbub
  • Repository
  • 1 Watchers
  • 0 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 25 % Grown

The README.md

Array to Text Table

forked from https://gist.github.com/tony-landis/31477, (*1)

This PHP class can convert an array into ascii text table., (*2)

Example Usage:

require_once ('ArrayToTextTable.php');

$data = array(
    array('company'=>'AIG', 'id'=>1, 'balance'=> '-$99,999,999,999.00'),
    array('company'=>'Wachovia', 'id'=>2, 'balance'=> '-$10,000,000.00'),
    array('company'=>'HP', 'id'=>3, 'balance'=> '$555,000.000.00'),
    array('company'=>'IBM', 'id'=>4, 'balance'=> '$12,000.00')
);

$renderer = new ArrayToTextTable($data);
$renderer->showHeaders(true);
$renderer->render();

Output of above example

+----------+----+---------------------+
| COMPANY  | ID |       BALANCE       |
+----------+----+---------------------+
| AIG      | 1  | -$99,999,999,999.00 |
| Wachovia | 2  | -$10,000,000.00     |
| HP       | 3  | $555,000.000.00     |
| IBM      | 4  | $12,000.00          |
+----------+----+---------------------+

Useful Methods:

render default: false

You can catch the output of the render with render(true), (*3)

$output = $renderer->render(true);

showHeaders default: false

Show the headers using the key values of the array for the titles, (*4)

$renderer->showHeaders(true);

setMaxWidth default: 30

Set the maximum width (number of characters) per column before truncating, (*5)

$renderer->setMaxWidth(30);

setMaxHeight default: 2

Set the maximum height (number of lines) per row before truncating, (*6)

$renderer->setMaxHeight(30);

The Versions

17/11 2017

dev-master

9999999-dev

This PHP class can convert an array into ascii text formatted table

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

17/11 2017

1.0.1

1.0.1.0

This PHP class can convert an array into ascii text formatted table

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0