rationalboss / array-to-text
本包最新版本(dev-master)没有提供许可证信息。
将PHP数组转换为纯文本表格。
dev-master
2017-02-11 08:02 UTC
This package is not auto-updated.
Last update: 2024-09-28 19:58:08 UTC
README
ArrayToText将PHP数组转换成文本表格。原始脚本:http://tonylandis.com/php/php-text-tables-class/。
<?php
$data = array(
array('company'=>'AIG', 'id'=>1, 'balance'=> '-$99,999,999,999.00'),
array('company'=>'Wachovia', 'id'=>2, 'balance'=> '-$10,000,000.00'),
array('company'=>'HP', 'id'=>3, 'balance'=> '$555,000.000.00'),
array('company'=>'IBM', 'id'=>4, 'balance'=> '$12,000.00')
);
$renderer = new ArrayToText($data);
$renderer->showHeaders(true);
$renderer->render();
// Using Composer:
/*
"require": {
"rationalboss/array-to-text": "dev-master"
}
*/
$data = array(
array('company'=>'AIG', 'id'=>1, 'balance'=> '-$99,999,999,999.00'),
array('company'=>'Wachovia', 'id'=>2, 'balance'=> '-$10,000,000.00'),
array('company'=>'HP', 'id'=>3, 'balance'=> '$555,000.000.00'),
array('company'=>'IBM', 'id'=>4, 'balance'=> '$12,000.00')
);
$renderer = new \rationalboss\util\ArrayToText($data);
$renderer->showHeaders(true);
$renderer->render();
?>
示例输出
+----------+----+---------------------+
| COMPANY | ID | BALANCE |
+----------+----+---------------------+
| AIG | 1 | -$99,999,999,999.00 |
| Wachovia | 2 | -$10,000,000.00 |
| HP | 3 | $555,000.000.00 |
| IBM | 4 | $12,000.00 |
+----------+----+---------------------+