Need to write php code to display a third level of categories
<p>I need some help with PHP. I dont deal with PHP but one of my client needs help.</p>

<p>From what I understand looking at the code below is that I need to add in some code to get the third level of categories from the database.</p>

<p>Below is the existing code to read the category and the second category level. I need to add in one more level to be read out from the database.</p>

<pre><code>$newcatarray = array();

// NOW WE BUILD A CLEAN ARRAY OF VALUES
foreach($cats as $cat){ 

    if($cat-&gt;parent != 0){ continue; }      
    $newcatarray[$cat-&gt;term_id]['term_id']  =  $cat-&gt;term_id;
    $newcatarray[$cat-&gt;term_id]['name']     =  $cat-&gt;cat_name;
    $newcatarray[$cat-&gt;term_id]['parent']   =  $cat-&gt;parent;
    $newcatarray[$cat-&gt;term_id]['slug']     =  $cat-&gt;slug;
    $newcatarray[$cat-&gt;term_id]['count']    =  $cat-&gt;count;
}
// SECOND LOOP TO GET CHILDREN
foreach($cats as $cat){

    if($cat-&gt;parent == 0){ continue; }
    $newcatarray[$cat-&gt;parent]['child'][] = $cat;        
}
</code></pre>

<p>This is the code that deals with displaying the categories on the site</p>

<pre><code>// UL LIST // NOT TOGGLE
            if(!empty($cat['child'])){

              $STRING .= '&lt;li&gt;&lt;a href="#"&gt;'.$cat['name'].''.$extra1.'&lt;/a&gt;&lt;ul class="listTab"&gt;';

                 $STRING .= '&lt;li&gt;&lt;a href="'.get_term_link( $cat['slug'], str_replace("_type","",$instance['type'])   ).'"&gt;'.$cat['name'].''.$extra1.'&lt;/a&gt;&lt;/li&gt;';

                 foreach($cat['child'] as $sub1){   

                    if($CATcOUNT == "yes"){ $extra2 = " (".$sub1-&gt;count.")"; }else{ $extra2 = ""; }

                    $STRING .= '&lt;li&gt;&lt;a href="'.get_term_link( $sub1-&gt;slug, str_replace("_type","",$instance['type'])   ).'"&gt;'.$sub1-&gt;name.''.$extra2.'&lt;/a&gt;&lt;/li&gt;';
                 }

                 $STRING .= '&lt;/ul&gt;&lt;/li&gt;';

             }else{

             $STRING .= '&lt;li&gt;&lt;a href="'.get_term_link( $cat['slug'], str_replace("_type","",$instance['type'])   ).'"&gt;'.$cat['name'].''.$extra1.'&lt;/a&gt;&lt;/li&gt;';

             } 
</code></pre>

<p>Can some one please help me out getting the third level of the category displaying on the site. Please help. Anything would be greatly appreciated.</p>

<p>Thanks,</p>
