function drush_print_table

8.0.x output.inc drush_print_table($rows, $header = FALSE, $widths = array(), $handle = NULL)
6.x output.inc drush_print_table($rows, $header = FALSE, $widths = array(), $handle = NULL)
7.x output.inc drush_print_table($rows, $header = FALSE, $widths = array(), $handle = NULL)
3.x drush.inc drush_print_table($rows, $header = FALSE, $widths = array())
4.x drush.inc drush_print_table($rows, $header = FALSE, $widths = array(), $handle = NULL)
5.x output.inc drush_print_table($rows, $header = FALSE, $widths = array(), $handle = NULL)
master output.inc drush_print_table($rows, $header = FALSE, $widths = array(), $handle = NULL)

Print a formatted table.

Parameters

$rows: The rows to print.

$header: If TRUE, the first line will be treated as table header and therefore be underlined.

$widths: The widths of each column (in characters) to use - if not specified this will be determined automatically, based on a "best fit" algorithm.

12 calls to drush_print_table()
drush_core_help in commands/core/core.drush.inc
This is called if no command or an unknown command is entered.
drush_core_status in commands/core/core.drush.inc
Command callback. Provides a birds-eye view of the current Drupal installation.
drush_core_watchdog_show_many in commands/core/watchdog.drush.inc
Print a table of watchdog messages.
drush_core_watchdog_show_one in commands/core/watchdog.drush.inc
Print a watchdog message.
drush_pm_info in commands/pm/pm.drush.inc
Command callback. Show detailed info for one or more projects.

... See full list

File

includes/drush.inc, line 986
The drush API implementation and helpers.

Code

function drush_print_table($rows, $header = FALSE, $widths = array()) {
  $tbl = new Console_Table(CONSOLE_TABLE_ALIGN_LEFT, '');

  $auto_widths = drush_table_column_autowidth($rows, $widths);

  // Do wordwrap on all cells.
  $newrows = array();
  foreach ($rows as $rowkey => $row) {
    foreach ($row as $col_num => $cell) {
      $newrows[$rowkey][$col_num] = wordwrap($cell, $auto_widths[$col_num], "\n", TRUE);
      if (isset($widths[$col_num])) {
        $newrows[$rowkey][$col_num] = str_pad($newrows[$rowkey][$col_num], $widths[$col_num]);
      }
    }
  }
  if ($header) {
    $headers = array_shift($newrows);
    $tbl->setHeaders($headers);
  }

  $tbl->addData($newrows);
  drush_print($tbl->getTable());
  return $tbl;
}