function draw_table($table)
{
    $nl = "\n";
    $columns_headers = columns_headers($table);
    $columns_lengths = columns_lengths($table, $columns_headers);
    $row_separator = row_seperator($columns_lengths);
    $row_spacer = row_spacer($columns_lengths);
    $row_headers = row_headers($columns_headers, $columns_lengths);
    echo '<pre>';
    echo $row_separator . $nl;
    echo str_repeat($row_spacer . $nl, SPACING_Y);
    echo $row_headers . $nl;
    echo str_repeat($row_spacer . $nl, SPACING_Y);
    echo $row_separator . $nl;
    echo str_repeat($row_spacer . $nl, SPACING_Y);
    foreach ($table as $row_cells) {
        $row_cells = row_cells($row_cells, $columns_headers, $columns_lengths);
        echo $row_cells . $nl;
        echo str_repeat($row_spacer . $nl, SPACING_Y);
    }
    echo $row_separator . $nl;
    echo '</pre>';
}
Exemple #2
0
function draw_table($main_array)
{
    $nl = "\n";
    $columns_headers = columns_headers($main_array);
    //echo '<br>$columns_headers:';
    //print_arr($columns_headers);
    $columns_lengths = columns_lengths($main_array, $columns_headers);
    //echo '<br>columns_lengths:';
    //print_arr($columns_lengths);
    $row_separator = row_separator($columns_lengths);
    //echo '<br>$row_separator:';
    //print_arr($row_separator);
    $row_spacer = row_spacer($columns_lengths);
    //echo '<br>$row_spacer:';
    //print_arr($row_spacer);
    $row_headers = row_headers($columns_headers, $columns_lengths);
    //echo '<br>$row_headers:';
    //print_arr($row_headers);
    echo '<pre>';
    //шапка таблицы
    echo $row_separator . $nl;
    echo $row_headers . $nl;
    //тело таблицы
    foreach ($main_array as $row_cells) {
        echo $row_separator . $nl;
        $row_cells = row_cells($row_cells, $columns_headers, $columns_lengths);
        echo $row_cells . $nl;
    }
    echo $row_separator . $nl;
    echo '</pre>';
}