I need to create the rows columns like this:

This is testing code im just implementing the logic for snapshot.
source code
$data = array('early','early','comment1','comment2','20','30');
function create_table($data)
{
$res = '<table width="200" cellpadding="1" cellspacing="1" border="1">';
$max_data = sizeof($data);
$ctr = 1;
foreach ($data as $db_data)
{
if ($ctr % 2 == 0) $res .= '<td>' . $db_data. '</td></tr>';
else
{
if ($ctr < $max_data) $res .= '<tr><td>' . $db_data. '</td>';
else $res .= '<tr><td colspan="2">' . $db_data. '</td></tr>';
}
$ctr++;
}
return $res . '</table>';
}
echo create_table($data);
html
<h2>Entry Fee</h2>
<table border="0" class="tb not-mobile">
<tr>
<td width="30%" rowspan="3">Early (Payment received by 1/4/15) </td>
<td width="58%">MD/DO</td>
<td width="12%" class="aligncenter">$23</td>
</tr>
<tr>
<td>CRNA/PA</td>
<td class="aligncenter">$37</td>
</tr>
<tr>
<td>RESIDENT/RN/OTHERS</td>
<td class="aligncenter">$49</td>
</tr>
<tr>
<td rowspan="3">Early (Payment received by 1/4/15) </td>
<td>MD/DO</td>
<td class="aligncenter">$23</td>
</tr>
<tr>
<td>CRNA/PA</td>
<td class="aligncenter">$37</td>
</tr>
<tr>
<td>RESIDENT/RN/OTHERS</td>
<td class="aligncenter">$49</td>
</tr>
</table>
- this raw html that snapshot shows.
- i trying build same logic similar as snapshot.
array structure
Array
(
[0] => Array(
[type] => General Public Tickets Adult
[metadata] => Array(
[0] => Array(
[amount] => 50
[comment] => (Working Days)
)
[1] => Array(
[amount] => 80
[comment] => (Saturday/ Sunday/ Holiday)
)
)
)
[1] => Array(
[type] => Special Tickets Children
[metadata] => Array(
[0] => Array(
[amount] => 300
[comment] => (Saturday/ Sunday/ Holiday)
)
[1] => Array(
[amount] => 10000
[comment] => (Monday afternoon)
)
)
)
)
