2017 © Pedro Peláez
 

library text-simpletable

travail/text-simpletable

image

travail/text-simpletable

travail/text-simpletable

  • Thursday, November 19, 2015
  • by travail
  • Repository
  • 1 Watchers
  • 5 Stars
  • 38,301 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 5 Versions
  • 3 % Grown

The README.md

Text\SimpleTable

NAME

Text\SimpleTable - Simple Eyecandy ASCII Tables, (*1)

SYNOPSIS

use Text\SimpleTable;

require_once '/path/to/vendor/autoload.php';

$table = new SimpleTable(10, 20);
$table->row('KEY1', 'VALUE1');
$table->row('KEY2', 'VALUE2');
$table->row('KEY3', 'VALUE3');
$table->row('KEY4', 'VALUE4');
$table->row('KEY5', 'VALUE5');
echo $table->draw();
/*
.------------+----------------------.
| KEY1       | VALUE1               |
| KEY2       | VALUE2               |
| KEY3       | VALUE3               |
| KEY4       | VALUE4               |
| KEY5       | VALUE5               |
'------------+----------------------'
*/

$table = new SimpleTable(array(10, 'KEY'), array(20, 'VALUE'));
$table->row('KEY1', 'VALUE1');
$table->row('KEY2', 'VALUE2');
$table->row('KEY3', 'VALUE3');
$table->row('KEY4', 'VALUE4');
$table->row('KEY5', 'VALUE5');
echo $table->draw();
/*
.------------+----------------------.
| KEY        | VALUE                |
+------------+----------------------+
| KEY1       | VALUE1               |
| KEY2       | VALUE2               |
| KEY3       | VALUE3               |
| KEY4       | VALUE4               |
| KEY5       | VALUE5               |
'------------+----------------------'
*/

$table = new SimpleTable(10, 20);
$table->row('KEY1', 'VALUE1');
$table->hr();
$table->row('KEY2', 'VALUE2');
$table->hr();
$table->row('KEY3', 'VALUE3');
echo $table->draw();
/*
.------------+----------------------.
| KEY1       | VALUE1               |
+------------+----------------------+
| KEY2       | VALUE2               |
+------------+----------------------+
| KEY3       | VALUE3               |
'------------+----------------------'
*/

$table = new SimpleTable(array(10, '国'), array(20, '首都'));
$table->row('日本', '東京');
$table->row('America', 'Washington D.C.');
$table->row('England', 'London');
$table->row('France', 'Paris');
$table->row('台湾', '台北');
// Set encoding, "UTF-8" by default.
// $table->setEncoding($encoding);
echo $table->draw();
/*
.------------+----------------------.
| 国         | 首都                 |
+------------+----------------------+
| 日本       | 東京                 |
| America    | Washington D.C.      |
| England    | London               |
| France     | Paris                |
| 台湾       | 台北                 |
'------------+----------------------'
*/

INSTALLATION

To install this package into your project via composer, add the following snippet to your composer.json. Then run composer install., (*2)

"require": {
    "travail/text-simpletable": "dev-master"
}

If you want to install from gihub, add the following:, (*3)

"repositories": [
    {
        "type": "vcs",
        "url": "git@github.com:travail/php-Text-SimpleTable.git"
    }
]

METHODS

__construct

__construct(int $width [, int $width [, ...]])

To draw simple table set $width to the number of columns., (*4)

__construct(array ($width, $col_name) [, array ($width, $col_name) [, ...]])

To draw table with header set $width and $col_name in array to the number of columns., (*5)

row

void row(string $value [, string $value [, ...]])

Draw row., (*6)

hr

void hr(void)

Draw horizontal rule., (*7)

setEncoding

void setEncoding(string $encoding)

To draw table with multibyte characters set current character encoding. UTF-8 by default., (*8)

getEncoding

string getEncoding()

Returns current character encoding., (*9)

draw

string draw(void)

Draw text table., (*10)

THANKS TO

Sebastian Riedel, sri@cpan.org., (*11)

AUTHOR

travail, (*12)

LICENSE

This library is free software. You can redistribute it and/or modify it under the same terms as PHP itself., (*13)

The Versions

19/11 2015

dev-master

9999999-dev

travail/text-simpletable

  Sources   Download

PHP-3.0

19/11 2015

v0.1.2

0.1.2.0

travail/text-simpletable

  Sources   Download

PHP-3.0

19/11 2015

dev-develop

dev-develop

travail/text-simpletable

  Sources   Download

PHP-3.0

24/07 2015

v0.1.1

0.1.1.0

travail/text-simpletable

  Sources   Download

PHP-3.0

01/05 2014

v0.1.0

0.1.0.0

travail/text-simpletable

  Sources   Download

PHP-3.0