格式化输出数组.
function pc_grid_horizontal($array, $size) { $table_width = 100; $width = intval($table_width / $size); $tr = '<tr align="center">'; $td = "<td width=\$width%%\">%s</td>"; $grid = "<table width=\"$table_width%%\">$tr"; $i = 0; foreach ($array as $e) { $grid .= sprintf($td, $e); $i ++; if (!$i % $size) { $grid .= "</tr>$tr"; } } while ($i % $size) { $grid .= sprintf($td, ' '); $i ++; } $end_tr_len = strlen($tr) * -1; if (substr($grid, $end_tr_len) != $tr) { $grid .= '</tr>'; } else { $grid = substr($grid, 0, $end_tr_end); } $grid .= '</table>'; return $grid; }