function drush_hide_empty_fields

8.0.x output.inc drush_hide_empty_fields($input, $fields)
6.x output.inc drush_hide_empty_fields($input, $fields)
7.x output.inc drush_hide_empty_fields($input, $fields)
master output.inc drush_hide_empty_fields($input, $fields)

Hide any fields that are empty

Related topics

1 call to drush_hide_empty_fields()
drush_rows_of_key_value_to_array_table in includes/output.inc
Convert an array of data rows, where each row contains an associative array of key : value pairs, into a table suitable for processing by drush_print_table. The provided $header determines the order that the items will appear in the output. Only data…

File

includes/output.inc, line 494

Code

function drush_hide_empty_fields($input, $fields) {
  $has_data = array();
  foreach ($input as $key => $data) {
    foreach ($fields as $field => $label) {
      if (isset($data[$field]) && !empty($data[$field])) {
        $has_data[$field] = TRUE;
      }
    }
  }
  foreach ($fields as $field => $label) {
    if (!isset($has_data[$field])) {
      unset($fields[$field]);
    }
  }
  return $fields;
}