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 585373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:59:45+00:00 2026-05-13T14:59:45+00:00

just want to ask anyone here can solve this problem? I want to create

  • 0

just want to ask anyone here can solve this problem?

I want to create a multilevel menu by generate with multilevel array.
I just can’t get perfect solution, it always got array_push error.
My study the original idea come from http://www.weberdev.com/get_example-4830.html

But still cannot match my need.

This is My MySQL

[code]
-----------------------------------------
|id | parent_id| name    | link     |seq
|1  |  0       |dashboad |dashboard/|1
|2  |  0       |menu1    |menu1/    |2
|3  |  0       |menu2    |menu2/    |3
|4  |  0       |menu3    |menu3/    |4
|5  |  2       |add      |add/      |1
|6  |  3       |add      |add/      |1
|7  |  2       |edit     |edit/     |2
|8  |  4       |add      |add/      |1
------------------------------------------
[/code]

I want my array some thing like this

array('dashboard'=>array(
                         'id'=>'',
                         'name'=>'dashboard',
                         'title'=>'dashboard',
                         'permalink'=>base_url().'dashboard/',
                         'active'=>FALSE,
                         'child'=>NULL
                         ),
     'menu1'=>array(
                         'id'=>'',
                         'name'=>'menu1',
                         'title'=>'menu1',
                         'permalink'=>base_url().'menu1/',
                         'active'=>FALSE,
                         'child'=>array(
                                       'add'=>array(
                                                     'id'=>'',
                                                     'name'=>'add',
                                                     'title'=>'add',
                                                     'permalink'=>base_url().'menu1/add',
                                                     'active'=>FALSE,
                                                     'child'=>NULL
                                                     ),
                                       'edit'=>array(
                                                     'id'=>'',
                                                     'name'=>'edit',
                                                     'title'=>'edit',
                                                     'permalink'=>base_url().'menu1/edit/',
                                                     'active'=>FALSE,
                                                     'child'=>NULL
                                                     )
                                                   ),
                                 ),
      ...................[similar like above]
                                       );       

I only able to do until push_array, but it has warning
Warning: array_push() [function.array-push]: First argument should be an array

I have this question had been discuss with a lot, but after I do some research most of the case are doing multilevel menu but in one level array. I want to achieve something multilevel array. Anyone can help?

The temporary array I am using static type.

  • 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-05-13T14:59:46+00:00Added an answer on May 13, 2026 at 2:59 pm

    [Solved]

    I have to declare the array first before I push it, else PHP can’t push the data inside, it will be empty. Praise the Lord!

    if(!isset($option_results[$nav_ParentName]['child']))
                        {
                            $option_results[$nav_ParentName]['child'] = array();  
                        }
                        $option_results[$nav_ParentName]['child'] = $option_results[$nav_ParentName]['child'] + $temp;
    

    but the thing for this solution is cannot declare $array[‘child’] = null;

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

Sidebar

Related Questions

Just want to ask can netbean IDE get connected to clearcase remote client server
Can you help me on this one? Just want to ask on how to
Just want to ask if i can use Custom Validator in client side without
I just want to ask if anybody has done something like this. Basically, it's
i just want to ask about my html code here, i have a bit
I just want to ask if there is any PHP/MySQL datatype that can store
i just want to ask, how can i save my json file from url
I just want to ask if anyone could help me write that image gallery?
Just want to ask why this wont work for me? I'm trying to bring
I just want to ask if is it okay that I use native PHP

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.