title: Recursion in codeigniter?
body: <p>I am trying to have a menu where the parent category can have as many child categories. The child categories can have as many sub child categories and so on......</p>
  
  <p>Eg:</p>
  
  <ul>
  <li>List item:
  <ul>
  <li>list 1</li>
  <li>list 2
  <ul>
  <li>list 2 a</li>
  <li>list 2 b
  <ul>
  <li>list 2 b i</li>
  </ul></li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>any insight for this ???</p>
  
  <p>PS. Using Codeigniter HMVC</p>
  
  <p>Currently I am working by :</p>
  
  <p>Using a helper function... </p>
  
  <p>I can view 2 level nested categories by the following code:</p>
  
  <pre><code>&lt;ul&gt;
      &lt;?php foreach($results as $row){ ?&gt;
      &lt;li&gt;
          &lt;?php echo $row-&gt;cat_title; ?&gt;
          &lt;?php 
          $childs = get_child_cat_by_id($row-&gt;cat_id);
          if(!empty($childs)){ ?&gt;
  
          &lt;ul&gt;
              &lt;?php  
              foreach($childs as $child){ ?&gt;
              &lt;li&gt;&lt;?php echo $child-&gt;cat_title; ?&gt;  
                  &lt;?php 
                  $sub_child = get_sub_childs($child-&gt;cat_id);
                  if(!empty($sub_child)){ ?&gt;
                  &lt;ul&gt;
                      &lt;?php  
                      foreach($sub_child as $children){ ?&gt;
                      &lt;li&gt;&lt;?php echo $children-&gt;cat_title; ?&gt;  &lt;/li&gt;
                      &lt;?php }?&gt;
                  &lt;/ul&gt;
                  &lt;?php } ?&gt;
  
              &lt;/li&gt;
              &lt;?php }?&gt;
          &lt;/ul&gt;
          &lt;?php } ?&gt;
  
      &lt;/li&gt;
      &lt;?php } ?&gt;
  &lt;/ul&gt; 
  </code></pre>
  
  <p>this code is used in the view. i need a recursive method so that the function get_child_cat_by_id need not be called many times. </p>