function _eck_fix_underscores in Entity Construction Kit (ECK) 7.2
Same name and namespace in other branches
- 7.3 includes/eck.drush.inc \_eck_fix_underscores()
Fix the table.
Replaces special separators in the table with lines that match the width of the column.
2 calls to _eck_fix_underscores()
- drush_eck_entity_construction_kit in includes/
eck.drush.inc - Implements drush_hook_command().
- drush_eck_entity_construction_kit_all in includes/
eck.drush.inc - Implements drush_hook_command().
File
- includes/
eck.drush.inc, line 162 - Drush support for ECK.
Code
function _eck_fix_underscores(&$rows) {
$widths = array_fill(0, count($rows[0]), 0);
$c = 0;
foreach ($rows as $row) {
$c = 0;
foreach ($row as $col) {
$widths[$c] = max($widths[$c], drupal_strlen($col));
$c++;
}
}
$tmp = json_encode($rows);
$c = 0;
foreach ($widths as $width) {
$tmp = str_replace("--{$c}--", str_repeat('-', $width), $tmp);
$c++;
}
$rows = json_decode($tmp);
}