Skip to content

Commit

Permalink
Merge pull request #1432 from natanfelles/cli_table
Browse files Browse the repository at this point in the history
Use mb_strlen to get length of columns
  • Loading branch information
lonnieezell authored Nov 9, 2018
2 parents 4d74f4d + f298294 commit 07977c2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions system/CLI/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ public static function table(array $tbody, array $thead = [])
foreach ($table_rows[$row] as $col)
{
// Sets the size of this column in the current row
$all_cols_lengths[$row][$column] = strlen($col);
$all_cols_lengths[$row][$column] = mb_strlen($col);

// If the current column does not have a value among the larger ones
// or the value of this is greater than the existing one
Expand All @@ -851,7 +851,7 @@ public static function table(array $tbody, array $thead = [])
$column = 0;
foreach ($table_rows[$row] as $col)
{
$diff = $max_cols_lengths[$column] - strlen($col);
$diff = $max_cols_lengths[$column] - mb_strlen($col);
if ($diff)
{
$table_rows[$row][$column] = $table_rows[$row][$column] . str_repeat(' ', $diff);
Expand All @@ -871,7 +871,7 @@ public static function table(array $tbody, array $thead = [])
$cols = '+';
foreach ($table_rows[$row] as $col)
{
$cols .= str_repeat('-', strlen($col) + 2) . '+';
$cols .= str_repeat('-', mb_strlen($col) + 2) . '+';
}
$table .= $cols . PHP_EOL;
}
Expand Down

0 comments on commit 07977c2

Please sign in to comment.