PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Console » Console_Table » Bug #4299

Cell Sizing Issues

Details

Submitted2005-05-06 19:46 UTC
Frommulka at umich dot edu
Assignedyunosh
StatusClosed
PackageConsole_Table
PHP Version4.3.5
Roadmaps(Not assigned)

Comments

[2005-05-06 19:46 UTC] mulka at umich dot edu

Description:
------------
The cell sizing is not working properly between the headers and the data. It seems to size them separately, and therefore causes the columns to not line up.

Reproduce code:
---------------
require_once "ConsoleTable.php";

$headers = array (
'name' => 'Lake Name',
'county' => 'County',
'township' => 'Township',
'section' => 'Section',
'site' => 'Site Name',
'latitude' => 'Latitude',
'longitude' => 'Longitude',
);

$data = array (
0 =>
array (
'name' => 'Crystal',
'county' => 'Benzie',
'township' => NULL,
'section' => NULL,
),
1 =>
array (
'name' => 'Ann',
'county' => '',
'township' => NULL,
'section' => NULL,
),
2 =>
array (
'name' => 'Ann',
'county' => '',
'township' => NULL,
'section' => NULL,
)
);

$table = new Console_Table();

$table->setHeaders($headers);
$table->addData($data);
print $table->getTable();

Expected result:
----------------
+-----------+--------+----------+---------+-----------+----------+-----------+
| Lake Name | County | Township | Section | Site Name | Latitude | Longitude |
+-----------+--------+----------+---------+-----------+----------+-----------+
| Crystal | Benzie | | | | | |
| Ann | | | | | | |
| Ann | | | | | | |
+-----------+--------+----------+---------+-----------+----------+-----------+

Actual result:
--------------
+---------+--------+--+--+--+--+--+
| Lake Name | County | Township | Section | Site Name | Latitude | Longitude | | | | | | | |
+---------+--------+--+--+--+--+--+
| Crystal | Benzie | | | | | |
| Ann | | | | | | |
| Ann | | | | | | |
+---------+--------+--+--+--+--+--+