--- /dev/null
+<?php
+
+class Table {
+ private $table;
+
+ public function Table($colums) {
+ $this->table = array();
+ $this->table['set'] = array();
+ $this->table['data'] = array();
+ $this->table['set']['col'] = $colums;
+ $this->table['set']['bold'] = array();
+ for($i = 0; $i < $this->table['set']['col']; $i++) {
+ $this->table['set']['max'.$i] = 0;
+ $this->table['set']['bold'][$i] = false;
+ }
+ }
+
+ public function setBold($colum) {
+ $this->table['set']['bold'][$colum] = true;
+ }
+
+ public function add() {
+ $args = func_get_args();
+ $row = array();
+ for($i = 0; $i < $this->table['set']['col']; $i++) {
+ if(count($args) <= $i) $args[$i]= "";
+ $row[] = $args[$i];
+ if(count($args) >= $i)
+ if(strlen($args[$i]) > $this->table['set']['max'.$i]) $this->table['set']['max'.$i] = strlen($args[$i]);
+ }
+ $this->table['data'][] = $row;
+ return true;
+ }
+
+ public function end() {
+ $space = " ";
+ $output = array();
+ for($row = 0; $row < count($this->table['data']); $row++) {
+ $out = "";
+ for($i = 0; $i < $this->table['set']['col']; $i++) {
+ if($i < $this->table['set']['col'] - 1)
+ $this->table['data'][$row][$i] .= substr($space,0,$this->table['set']['max'.$i] - strlen($this->table['data'][$row][$i]) + 1);
+ $bold = $this->table['set']['bold'][$i];
+ $out .= ($bold ? "\002" : "").$this->table['data'][$row][$i].($bold ? "\002" : "");
+ }
+ $output[] = $out;
+ }
+ return $output;
+ }
+
+}
+
+?>
\ No newline at end of file