php appending inside foreach, what is the use of appending to a variable.
<p>How to append the code to a variable.</p>

<pre><code>&lt;?php
echo "&lt;ul&gt;\n";
    foreach($related as $r) {

        if ($r-&gt;Count &gt; 0) {
            echo "&lt;li&gt;" . "&lt;a&gt;". $r-&gt;post_title ."&lt;/a&gt;". "\n";
      f_tree_av($r-&gt;post_id, $level + 1);
      echo "&lt;/li&gt;";
        } elseif ($r-&gt;Count==0) {
            echo "&lt;li&gt;" . "&lt;a&gt;". $r-&gt;post_title ."&lt;/a&gt;". "\n";
        } else;
    }
    echo "&lt;/ul&gt;\n";
?&gt;
</code></pre>
