Home » HTML » HTML_Table » Bug #4988
addRow don't work with incomplete array
Details
| Request #4988 | addRow don't work with incomplete array |
|---|---|
| Submitted | 2005-08-03 15:41 UTC |
| From | albsala at gmail dot com |
| Assigned | wiesemann |
| Status | Closed |
| Package | HTML_Table |
| PHP Version | 4.3.11 |
| OS | GNU/Linux |
| Roadmaps | (Not assigned) |
Comments
[2005-08-03 15:41 UTC] albsala at gmail dot com
Description:
------------
If you add an array without all column numbers as a new row, addRow don't work as it should be.
//This code:
$row = array(1 => "Cell1", 2 => "Cell2", 5 => "Cell5");
$table->addRow($row);
//only insert cell 1 and 2.
Test script:
---------------
//Lines 349-355 (addRow method):
for ($counter = 0; $counter < count($contents); $counter++) {
if ($type == 'TD') {
$this->setCellContents($row, $counter, $contents[$counter]);
} elseif ($type == 'TH') {
$this->setHeaderContents($row, $counter, $contents[$counter]);
}
}
//should be:
foreach ($contents as $col => $content) {
if ($type == 'TD') {
$this->setCellContents($row, $col, $content);
} elseif ($type == 'TH') {
$this->setHeaderContents($row, $col, $content);
}
}
[2005-10-20 13:51 UTC] post at markwiesemann dot de
I can reproduce this problem with current CVS version and have tested the suggested solution - it works as expected.
Here is a patch for Table/Storage.php:
www.markwiesemann.de/php/HTML_Table/Bug_4944.patch
I can commit it myself, if you want.