lucasjs7/simple-cli-table

一个简单的库,用于在PHP中渲染表格。

v1.04 2024-04-21 14:27 UTC

This package is auto-updated.

Last update: 2024-09-27 14:44:29 UTC


README

一个简单的库,用于在PHP中渲染表格。

示例 1

# Code:
$data = [
	['First Name', 'Last Name', 'Age'],
	['Steve',      'Magal',     '37'],
	['Jorel',      'Seila',     '14'],
	['William',    'Shostners', '9'],
	['Carlos',     'Felino',    '39'],
];

echo SimpleCliTable::build($data);

# Output:
+------------+-----------+-----+
| First Name | Last Name | Age |
+------------+-----------+-----+
| Steve      | Magal     | 37  |
| Jorel      | Seila     | 14  |
| William    | Shostners | 9   |
| Carlos     | Felino    | 39  |
+------------+-----------+-----+

示例 2

# Code:
$data = [
	['Steve',      'Magal',     '37'],
	['Jorel',      'Seila',     '14'],
	['William',    'Shostners', '9'],
	['Carlos',     'Felino',    '39'],
];

$simpleTableCli = new SimpleCliTable;
$simpleTableCli->setContainsHeader(false);

foreach ($data as $line) {
	$simpleTableCli->add($line);
}

echo $simpleTableCli->render();

# Output:
+---------+-----------+----+
| Steve   | Magal     | 37 |
| Jorel   | Seila     | 14 |
| William | Shostners | 9  |
| Carlos  | Felino    | 39 |
+---------+-----------+----+

使用composer安装

composer require lucasjs7/simple-cli-table