How to determine the first element in a recursive foreach function?
<p>I have a function generating nested navigation menu:</p>

<pre><code>function recursive_foreach($array, $display) {
$out     = '&lt;ul&gt;';
foreach($array as $key =&gt; $value) {
... 
     $out .= '&lt;li class="'. $is_active . $is_parent . '"&gt;&lt;a href="' . $url . '"&gt;' . $value['name'] . '&lt;/a&gt;';    }   
...     
     $out .= "&lt;/li&gt;";
}   
$out .= '&lt;/ul&gt;';    
return $out;    
}
</code></pre>

<p>I want to add css class just to the first "ul" element. I know how to determine first element inside foreach loop but how can I get it outside of it?</p>
