Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8875585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:00:38+00:00 2026-06-14T19:00:38+00:00

I put the below function inside a class I try to call it again

  • 0

I put the below function inside a class

I try to call it again inside this function (I have made a recursive call inside this function $this->buildMenu($this->itemId, $menuData);)

only without the recursive call this function works, else it does not return any value.

// menu builder function, parent_id 0 is the root 
function buildMenu($parent_id, $menuData)
{       
    $this->html = ''; 
    if (isset($menuData['parents'][$parent_id])) 
    { 
        if($parent_id=='0') $this->html = '<ul class="menu responsive-menu sf-js-enabled">';
        else $this->html = '<ul>';
        foreach ($menuData['parents'][$parent_id] as $this->itemId) 
        { 
            if($this->itemId=='1'){$this->html .= '<li><a href="'.PATH.'">' . $menuData['items'][$this->itemId]['menu_name'].'</a>';}
            else $this->html .= '<li class=""><a href="?action='. md5($menuData['items'][$this->itemId]['menu_link']).'">' . $menuData['items'][$this->itemId]['menu_name'].'</a>';
            $this->html .= $this->buildMenu($this->itemId, $menuData); 
            $this->html .= '</li>'; 
        } 
        $this->html .= '</ul>'; 
    } 

    return $this->html;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:00:39+00:00Added an answer on June 14, 2026 at 7:00 pm

    The problem might be with $this->html = '';.
    It seems like $html is a class variable, so each recursive call to the function, you initialize it to be an empty string.
    Try using it as a local function variable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the below function creating new panels inside my ViewStack.. This works fine
I have managed to put this condition and rule below together to redirect a
I have a recursive function which contains some drawing code inside. I was advised
I have a model: <?php class Loginfunctionmodel extends CI_Model{ function __construct() { // Call
Why can't I put the function below inside jQuery(document).ready(function() { } ? function csf_map_maker_js(
When I put the below function into leon repl , I get java.lang.IllegalArgumentException: Wrong
how to put this code below? - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { NSString *year
So I have a java hashmap like below: hMap.put(1, One); hMap.put(2, Two); hMap.put(3, Two);
i want to put the id into the colorbox below this code nom works
I have a function that searches for a string inside a text file. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.