PHP code example of travail / text-simpletable
1. Go to this page and download the library: Download travail/text-simpletable library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
travail / text-simpletable example snippets
use Text\SimpleTable;
ble(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 |
| 台湾 | 台北 |
'------------+----------------------'
*/
__construct(int $width [, int $width [, ...]])
__construct(array ($width, $col_name) [, array ($width, $col_name) [, ...]])
void row(string $value [, string $value [, ...]])
void hr(void)
void setEncoding(string $encoding)
string getEncoding()
string draw(void)