分组数组中的PHP数组分组

I am already grouping my primary array, so I can display a tab format of DNS record types. In each tab is displayed all DNS records that exist in said type

For instance:

[22] => Array
    (
        [dnsType] => MicrosoftDNS_AType
        [dnsDomain] => 1fit.net
        [dnsOwner] => 1fit.net
        [dnsIP] => 127.0.0.1
        [dnsText] => 1fit.net IN A 127.0.0.1
        [dnsTTL] => 3600
    )

[23] => Array
    (
        [dnsType] => MicrosoftDNS_AType
        [dnsDomain] => 1fit.net
        [dnsOwner] => mail.1fit.net
        [dnsIP] => 127.0.0.1
        [dnsText] => mail.1fit.net IN A 127.0.0.1
        [dnsTTL] => 3600
    )

[24] => Array
    (
        [dnsType] => MicrosoftDNS_AType
        [dnsDomain] => 1fit.net
        [dnsOwner] => www.1fit.net
        [dnsIP] => 127.0.0.1
        [dnsText] => www.1fit.net IN A 127.0.0.1
        [dnsTTL] => 3600
    )

How can I break this down further by grouping on dnsDomain? In such that all 3 records above appear under a main "domain" in a table

Right now, all I can seem to do is get them all to display: http://prntscr.com/58oov5

What I'd like is these 3 condensed into 1 row, with a ul of the 3 records... at least then I can make is collapsible, so only the 1st record will show as the link...

Here's my attempt thus far:

<div id="tab-content" class="tab-content">
<?php
    $gCt = count($groups);
    for($i=0;$i<$gCt;++$i){
        $cls = ($i == 0) ? ' active' : '';
        echo '<div class="tab-pane'.$cls.'" id="' . strtolower(str_replace('Type', null, str_replace('MicrosoftDNS_', null, $groups[$i]))) . '">
            <div class="content-container">
                <h3>' . str_replace('Type', null, str_replace('MicrosoftDNS_', null, $groups[$i])) . ' Records</h3>';
        echo '<div class="table-responsive">
            <table class="table table-striped">
                <thead>
                    <tr>
                        <th>Domain</th>
                        <th>IP</th>
                        <th>TTL</th>        
                    </tr>       
                </thead>';
            $recs = array_values(filter_by_value($dns, 'dnsType', $groups[$i]));        
            $rCt = count($recs);
        echo '<textarea style="width:100%;height:200px;">';
        print_r($recs);
        echo '</textarea>';
            for($j = 0; $j < $rCt; ++$j){
                $domains = array_values(filter_by_value($recs, 'dnsDomain', $recs[$j]['dnsDomain']));
                $dCt = count($domains);
                echo '<tr>
                        <td><a href="#" onclick="return false;" title="TEXT: ' . $recs[$j]['dnsText'] . '">' . $recs[$j]['dnsOwner'] . '</a></td>
                        <td>' . $recs[$j]['dnsIP'] . '</td>
                        <td>' . $recs[$j]['dnsTTL'] . '</td>
                    </tr>';
            }
        echo '
            </table>
        </div>';
        echo '</div>
            </div>';

    }
?>
</div>
<?php
function filter_by_value ($array, $index, $value){ 
if(is_array($array) && count($array)>0)  
{ 
    foreach(array_keys($array) as $key){ 
        $temp[$key] = $array[$key][$index]; 

        if ($temp[$key] == $value){ 
            $newarray[$key] = $array[$key]; 
        } 
    } 
  } 
return $newarray; 
} 
?>

And the functions pulling in $groups and $dns (it's codeigniter)

function dns(){
    $data['dns'] = $this->servers_model->get_DNS();
    $tmpGrp = $this->array_group_by($data['dns'], 'dnsType');
    $_tmparr = array();
    $i = 0;
    foreach($tmpGrp as $key => $value) {
        $_tmparr[$i] = $key;
        ++$i;
    }       
    $data['groups'] = $_tmparr;
    $this->load->view('templates/header', $data);
    $this->load->view('servers/dns', $data);
    $this->load->view('templates/footer', $data);
}

function array_group_by($array, $key) {
    $return = array();
    foreach($array as $val) {
        $return[$val[$key]][] = $val;
    }
    return $return;
}