Set active class in a Php foeach
<p>I have the following code to display a list of taxonomies in Wordpress. It works and my only concern is the active class (li class="active"). Err, how do I go about making it dynamic?</p>

<pre><code>        &lt;ul id="filter"&gt;    
        &lt;?php       
        echo '&lt;li class="active"&gt;&lt;a href="#" class="all"&gt;All&lt;/a&gt;&lt;/li&gt;'; # this remains static and unchanged             
            if ( $count &gt; 0 ) {             
                foreach ( $mylinks as $mylink ) {
                    echo '&lt;li&gt;';
                    # get current webdirectory and link to taxonomy menus
                    echo'&lt;a href=' . network_site_url() . '/services/' .$mylink-&gt;slug . ' class='. $mylink-&gt;slug .'" &gt;';
                    echo $mylink-&gt;name;
                    echo "&lt;/a&gt;";
                    echo "&lt;/li&gt;";
                }
            }   
        ?&gt;
    &lt;/ul&gt;
</code></pre>
