air-petr/php-tabulator
Composer 安装命令:
composer require air-petr/php-tabulator
包简介
Tabular data in PHP
关键字:
README 文档
README
Pretty-print the tabular data in various ways.
Instalation
composer require ar-petr/php-tabulator
Usage
You will get a Tabulator class with a static interface:
use AirPetr\Tabulator; $body = [ [1, 'Lila', 'Hevner'], [2, 'Florrie', 'Gravie'], ]; $header = ['id', 'first_name', 'last_name']; echo Tabulator::getPlain($body); // Table without headers echo Tabulator::getPlain($body, $header); // Table with headers
There are different types of output:
Plain
echo Tabulator::getPlain($data, $headers); /* id first_name last_name 1 Lila Hevner 2 Florrie Gravie */
Simple
echo Tabulator::getSimple($data, $headers); /* id first_name last_name -- ---------- --------- 1 Lila Hevner 2 Florrie Gravie */
GitHub
echo Tabulator::getGitHub($data, $headers); /* | id | first_name | last_name | | -- | ---------- | --------- | | 1 | Lila | Hevner | | 2 | Florrie | Gravie | */
More types may be added in the future.
Numbers
Columns with numbers are flushed to the left.
| ip_address | age | account |
| --------------- | ---- | -------- |
| 219.249.38.228 | 2362 | 12276.68 |
| 197.81.54.113 | 41 | 6496.03 |
| 176.111.139.6 | 64 | 3291.72 |
| 208.178.177.206 | 34 | 4311.57 |
Demo
You can see some examples by running scripts from a demo folder:
php demo/plain.php
php demo/github.php
# etc.
Testing
Run tests by:
composer test
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-02-04