How to list Tags using get_tags in an html table?

This is what I tried and it works well. I am using array_chunk, but I’m also adding a check to see if a chunk has less than 4 values (as you want 4 columns), then just add a blank <td>, which will avoid the mark up from breaking.

<?php
$tags = get_tags(array('hide_empty' => false));
$tag_groups = array_chunk($tags, 4);
$t="<table>";
foreach($tag_groups as $tag_single)
{   
    $t .= '<tr>';
    for($i = 0; $i < 4; $i++)
    {
        if(isset($tag_single[$i]) && !empty($tag_single[$i]))
        {
            $tag_link = get_tag_link($tag_single[$i]->term_id);
            $t .= "<td><a href="".$tag_link."" title="".$tag_single[$i]->name."">".$tag_single[$i]->name."</a></td>";
        }
        else
        {
            $t .= "<td></td>";
        }
    }
    $t .= '</tr>';
}

echo $t .= "</table>";
?>

Hope it helps!

tech