aschmelyun/ markdown-table
动态生成Markdown表格
1.0.0
2017-06-02 13:16 UTC
Requires
- php: >=5.4.0
- illuminate/contracts: ^5.0
This package is auto-updated.
Last update: 2024-09-21 13:42:23 UTC
README
这是一个用于动态生成Markdown表格的小型包,详细说明请参见这里。
安装
使用composer安装
composer require maddhatter/markdown-table
用法
// create instance of the table builder $tableBuilder = new \MaddHatter\MarkdownTable\Builder(); // add some data $tableBuilder ->headers(['Tables','Are','Cool']) //headers ->align(['L','C','R']) // set column alignment ->rows([ // add multiple rows at once ['col 1 is', 'left-aligned', '$1600'], ['col 2 is', 'centered', '$12'], ]) ->row(['col 3 is', 'right-aligned', '$1']); // add a single row // display the result echo $tableBuilder->render();
结果
| Tables | Are | Cool |
|----------|:-------------:|------:|
| col 1 is | left-aligned | $1600 |
| col 2 is | centered | $12 |
| col 3 is | right-aligned | $1 |