Row 1, Column 1 | Row 1, Column 2 |
Row 2, Column 1 | Row 2, Column 2 |
$table = new HtmlTable(); $table->setClass("table-style"); $table->addRow(array("Row 1, Column 1", "Row 1, Column 2")); $table->addRow(array("Row 2, Column 1", "Row 2, Column 2")); echo $table->toHtml();
$table1 = new HtmlTable(); $table1->setClass("table-style"); $table1->addRow(array("Row 1, Column 1", "Row 1, Column 2")); $table1->addRow(array("Row 2, Column 1", "Row 2, Column 2")); $table2 = new HtmlTable(); $table2->setClass("table-style"); $table2->addRow(array("Row 1, Column 1", "Row 1, Column 2")); $table2->addRow(array("Row 2, Column 1", "Row 2, Column 2")); echo $table1->toHtml() . $table2->toHtml();In this example, we set the class attribute value to "table-style" for two separate instances of the HtmlTable class. Both tables have the same CSS styles applied to them, making it easier to style multiple tables using the same CSS code. The HtmlTable class is typically part of a package or library for generating HTML code using PHP. Some popular HTML generation libraries include Laravel Collective, Symfony Form Builder, and PHP Form Builder.