public function toTable()
{
$output = '';
if (!isset($this->_rows)) {
$this->parse();
}
if (!empty($this->_rows)) {
// Begin table.
$output = '<table border="1" cellspacing="1" cellpadding="3">';
// Table head.
$output .= '<thead><tr><th> </th>';
foreach ($this->_rows as $row) {
foreach ($row as $key => $col) {
$output .= '<th>' . $key . '</th>';
}
break;
}
$output .= '</tr></thead>';
// Table body.
$output .= '<tbody>';
foreach ($this->_rows as $i => $row) {
$output .= '<tr>';
$output .= '<th>' . $i . '</th>';
foreach ($row as $col) {
$output .= '<td>' . $col . '</td>';
}
$output .= '</tr>';
}
$output .= '</tbody>';
// Close table.
$output .= '</table>';
}
return $output;
}