how to write the condition?
<pre><code>$tree = taxonomy_get_tree($vid);
print "&lt;li&gt;";                    // 1 line 
foreach ($tree as $term ) {      // 2 lines
   $diffdepth=0;
   if ($term-&gt;depth &gt; $depth) {
      print "&lt;ul class='haschild'&gt;&lt;li&gt;";
      $depth = $term-&gt;depth;
   }
</code></pre>

<p>the above is the original code, now I want according to <code>$term-&gt;depth &gt; $depth</code>  make a condition to output.( <code>print "&lt;li&gt;";</code>  ) this line.</p>

<p>namely,  </p>

<pre><code>if ($term-&gt;depth &gt; $depth) { 
   echo '&lt;li class="parent"&gt;'; 
} 
else { 
   print "&lt;li&gt;"; 
}
</code></pre>

<p>but <code>$term-&gt;depth</code> can use after foreach loop, but i want to use it at 1 line, how do i do?</p>
