I have been using the following function (in the kohana html class in a table) to generate tables.
function table($columns,$reverse=false,$fill=false,array $attr=null){
$c = '';
//ugly hack, looking for fix
$max=sizeof(max($columns));
for($i=0;$i<sizeof($columns);$i++){
$column = $columns[$i];
if($fill==true){
$l = ($max-sizeof($column));
for($ii=0;$ii<$l;$ii++){
array_push($column,'');
}
}
if($reverse==true){
$columns[$i] = array_reverse($column);
}else{
$columns[$i] = $column;
}
}
for($i=0,$l=sizeof($columns);$i<$l;$i++){
$column = $columns[$i];
$c.="<tr>";
for($ii=0,$ll=sizeof($column);$ii<$ll;$ii++){
$c.="<td>".$column[$ii]."</td>";
}
$c.="</tr>";
}
return "<table".html::attributes($attr).">".$c."</table>";
}
And then I have been calling it like so:
echo html::table(array(
array('colunm 1 row 1','colunm 2 row 1'),
));
And a reversed table that auto fills the columns.
echo html::table(array(
array('colunm 1 row 1','colunm 2 row 1'),
array('column 1 row 2','column 2 row 2')
),true,true);