title: How to call recursive function in smarty?
body: <pre><code>$sql = "select menu_id , menu_name , parent_id from menu " ;
  $dbc-&gt;setFetchMode(DB_FETCHMODE_ASSOC);
  $res = $dbc-&gt;query($sql);
  while($row = $res-&gt;fetchRow()){
      $menu[$row['parent_id']][$row['menu_id']] = $row['menu_name'];
  }
  
  function make_menu($parent)
  {
      global $menu ;
      echo '&lt;ul&gt;';
      foreach($parent as $menu_id=&gt;$menu_name)
      {
          echo '&lt;li&gt;'.$menu_name ; 
          if(isset($menu[$menu_id]))
          {
              make_menu($menu[$menu_id]) ;
          }
          echo '&lt;/li&gt;';
      }
      echo '&lt;/ul&gt;';
  }
  $P['menu_bilder_data'] = $menu[0] ; 
  //menu :off
  $smarty-&gt;register_function('make_menu' , 'make_menu') ;
  </code></pre>
  
  <p>ok i have this section of code to retrieve and pass to smarty.</p>
  
  <p>I have registered my <code>make_menu</code> function as a custom user function with smarty, and in the template i have this code:</p>
  
  <pre><code>{make_menu parent_id=$P.menu_bilder_data}
  </code></pre>
  
  <p>I'm passing <code>$P</code> array in index file. It must work but it gives me nothing because it's a recursive function, it returns an array instead of printed nested uls; how can i fix this issue?</p>