Skip to content

Instantly share code, notes, and snippets.

@estefanionsantos
Created September 15, 2021 20:17
Show Gist options
  • Save estefanionsantos/ed41f25bae5ca6cc7d8063f06fb2755a to your computer and use it in GitHub Desktop.
Save estefanionsantos/ed41f25bae5ca6cc7d8063f06fb2755a to your computer and use it in GitHub Desktop.
table.example01
<?php
$data = include 'dataArr.php';
$table = new Rubricate\Table\ContainerTable();
$header = new Rubricate\Table\HeadRowTable();
$body = new Rubricate\Table\BodyTable();
$table->setAttribute('border', '1');
$header->addHead('#');
$header->addHead('Name');
$header->addHead('Occupation');
$header->addHead('User');
$table->addChild($header);
foreach ($data as $k => $row)
{
$ln = new Rubricate\Table\RowTable();
$ln->addData($row['id']);
$ln->addData($row['name']);
$ln->addData($row['occupation']);
$ln->addData($row['user']);
$body->addChild($ln);
}
$table->addChild($body);
echo $table->getElement();
/*
<table border="1">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Occupation</th>
<th>User</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>John</td>
<td>Engineer</td>
<td>@john</td>
</tr>
<tr>
<td>2</td>
<td>Mary</td>
<td>Doctor</td>
<td>@mary</td>
</tr>
<tr>
<td>3</td>
<td>Joseph</td>
<td>Dentist</td>
<td>@joseph</td>
</tr>
</tbody>
</table>
* */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment