rationalboss / array-to-text
Convert PHP arrays to plain text table.
Installs: 58
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/rationalboss/array-to-text
This package is not auto-updated.
Last update: 2025-09-28 02:20:43 UTC
README
ArrayToText will transform a PHP array to a textual table. Original script: 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();
?>
Sample Output:
+----------+----+---------------------+
| 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 |
+----------+----+---------------------+