protected function alignTdContent(&$content, $col) { if (!isset($this->table['aligns'][$col])) { $this->table['aligns'][$col] = 'left'; } switch ($this->table['aligns'][$col]) { default: case 'left': $content .= str_repeat(' ', $this->table['col_widths'][$col] - $this->strlen($content)); break; case 'right': $content = str_repeat(' ', $this->table['col_widths'][$col] - $this->strlen($content)) . $content; break; case 'center': $paddingNeeded = $this->table['col_widths'][$col] - $this->strlen($content); $left = floor($paddingNeeded / 2); $right = $paddingNeeded - $left; $content = str_repeat(' ', $left) . $content . str_repeat(' ', $right); break; } }