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

  • SEARCH
  • Home
  • 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 8700445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:10:15+00:00 2026-06-13T02:10:15+00:00

I have put together a menu using a md array, but I am having

  • 0

I have put together a menu using a md array, but I am having problems getting the sub menu items to print out properly.

I use this to build the menus:

class Language {

public $langCode ;

function __construct($code)
{
    $this->langCode = $code ;
}

public function navigation()
{
    if($this->langCode == 'en')
    {
        $menu = array(
                      array('Home', ''),
                      array('Galleries', '',
                            array('Top ten hottest' => 'hottest.php'),
                            array('Top ten worst' => 'hottest.php'),
                           ),
                      array('Upload', 'upload.php'),
                      array('Login/register', ''),
                      array('Resources', '', 
                            array('News' => ''),
                            array('What\'s a mound?' => ''),
                            array('Legal' => ''),
                            array('Links' => ''),
                           ),
                      array('abc?', ''),
                     ) ;
    }
    return $menu ;
}

}

And I am trying to build the menu using:

$mainMenu = $lng->navigation() ;

echo "<ul>\n" ;
foreach($mainMenu as $set) {
    $x = 0 ;
    echo "<li><a href='".$set[1]."'>".$set[0]."</a></li>\n" ;
    if($set[2])
    {
        foreach($set[2] as $label => $item) {
            echo $item ;
        }
    }
}

But all I’m getting is the first item from the sub menu from the foreach loop which makes no sense to me because I can access it directly by doing $set[2][0] (before I assigned keys to the values in the arrays).

What do I need to do to get the output I want?

  • 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-13T02:10:16+00:00Added an answer on June 13, 2026 at 2:10 am

    You are forgetting to make set[2] an array. Right now you have set[2] and set[3] and on resources you have set[4] and set[5] also:

    $menu = array(
                      array('Home', ''),
                      array('Galleries', '', array(
                            array('Top ten hottest' => 'hottest.php'),
                            array('Top ten worst' => 'hottest.php'),
                           )),
                      array('Upload', 'upload.php'),
                      array('Login/register', ''),
                      array('Resources', '', array(
                            array('News' => ''),
                            array('What\'s a mound?' => ''),
                            array('Legal' => ''),
                            array('Links' => ''),
                           )),
                      array('abc?', ''),
                     ) ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple accordion menu I've put together today using the jQuery slideDown()
I have put together an image scroller using jquery, like this function rotateImages(whichHolder, start)
I've tried to put together a solution from similar questions but have failed miserably.
I have put together a couple of jquery carousel's using either Tiny Carousel or
I have put together some code from various sources but javascript is somewhat unknown
I have put together a HTTP driven API using the WCF WebAPI that uses
I have put together this simple code for showing/hiding some content on click using
I have put together a very complicated search form. Using arrays I have managed
I have put together an ajax powered chat/social network with jquery, PHP - but
I have put together a script to delete backed up files, but believe 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.