Reuse Same Function inside a Function
<p>I've been thinking of the best way to create a dynamically nested <ul> navigation using PHP, and that is to use a function that gets called within the same function to generate the different navigation levels.</p>

<p>I have a database that consists of 3 fields:</p>


<li>page - Used as a unique identifier for the navigation item</li>
<li>title - Used to store the title of the navigation item.</li>
<li>owner - used to store what page this page is associated to. (Parent page)</li>
</ul>

<p>I'm trying to make the followed menu dynamic</p>

<pre><code>&lt;ul&gt;
    &lt;li&gt;&lt;a href="#"&gt;Menu 1&lt;/a&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href="#"&gt;Sub Menu 1&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href="#"&gt;Sub Menu 2&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href="#"&gt;Sub Menu 3&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href="#"&gt;Sub Menu 4&lt;/a&gt;
                &lt;ul&gt;
                    &lt;li&gt;&lt;a href="#"&gt;Sub Menu 1 of Sub Menu 4&lt;/li&gt;
                    &lt;li&gt;&lt;a href="#"&gt;Sub Menu 2 of Sub Menu 4&lt;/li&gt;
                    &lt;li&gt;&lt;a href="#"&gt;Sub Menu 3 of Sub Menu 4&lt;/li&gt;
                &lt;/ul&gt;
            &lt;/li&gt;
        &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;&lt;a href="#"&gt;Menu 2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>I'm having issues, as the page crashes upon calling the function again inside the same function, as it creates a continuous loop. How do I prevent this from happening?</p>

<p>Thanks!</p>
