PHP Table generation
Didn't test, but I would write it something like this:

function table($rows, $reverse = false, $fill = false, array $attr = null) {
    $c = '';
    $max_cols = sizeof(max($columns));

    foreach ($rows as $columns) {
        if ($fill &amp;&amp; sizeof($columns) &lt; $max_cols) {
            $columns = array_merge($columns, array_fill(0, $max_cols - sizeof($columns), ''));
        }
        if ($reverse) {
            $columns = array_reverse($columns);
        }
        $c .= '&lt;tr&gt;&lt;td&gt;' . implode('&lt;/td&gt;&lt;td&gt;', $columns) . '&lt;/td&gt;&lt;/tr&gt;';
    }

    return '&lt;table&gt;' . $c . '&lt;/table&gt;';
}