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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:56:50+00:00 2026-06-14T11:56:50+00:00

I have a multi-dimensional array (something as below). What am trying to do is

  • 0

I have a multi-dimensional array (something as below). What am trying to do is find a specific value, and if that value has children, list only those children. So for example, if am searching for slug’s “test”, then all of “test’s” children list on the page. “Test2” has no children, so none listed. If am searching for “/test/sub” (the slug), and since it has children, I wanted to show all of the children (eg. “sh”, “rd”, “co”). Am lost as to how to begin with this, so any help is greatly appreciated.

    Array
    (
     [test] => Array
      (
        [children] => Array
         (
           [2] => Array
             (
               [parent] => 4
               [title] => Sub
               [slug] => test/sub/
               [id] => 2
               [children] => Array
               (
                 [3] => Array
                 (
                   [parent] => 2
                   [title] => sh 
                   [slug] => test/sub/sh
                   [id] => 3
                 )
                 [27] => Array
                 (
                   [parent] => 2
                   [title] => RD
                   [slug] => test/sub/rd
                   [id] => 27
                 )
                 [145] => Array
                 (                                     
                   [parent] => 2
                   [title] => cO
                   [slug] => test/sub/co
                   [id] => 145
                 )
               )
            )
            [8] => Array
            (
              [parent] => 4
              [title] => sub2
              [slug] => test/sub2
              [id] => 8
            )
            [19] => Array
            (
              [parent] => 4
              [title] => sub3
              [slug] => test/sub3
              [id] => 19
              [children] => Array
              (
                [20] => Array
                (
                 [parent] => 19
                 [title] => child1
                 [slug] => test/sub3/child1
                 [id] => 20
                )
                [21] => Array 
                (
                 [parent] => 19     
                 [title] => child2
                 [slug] => test/sub3/child2                                                                                          [id] => 21
                 )
               )
            )
  • 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-14T11:56:52+00:00Added an answer on June 14, 2026 at 11:56 am

    Ok. I have a way around this, but I am not sure if its the most efficient. Suppose the object that you get after querying the database is $anObject. So we would do,

    for($i = 0;$i < 50;$i++){
    if($anObject->test->children[$i]){
    for($j = 0;$j < 200;$j++){
    $slug = $anObject->test->children[$i]->$j->slug;
    echo $slug;
    }
    }}
    

    Basically, I am checking if a particular an object exists for a particular value of $i and then see if it has a value for a particular value of $j. You could change these values if you know the range of the integers. When we get it we grab it in a $slug variable, and then you add some procedure in that part to use this value.

    Let me know if this was of any help.

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

Sidebar

Related Questions

I have a multi dimensional array. The only actual values (other than other arrays)
I have an multi-dimensional array that I want to send to a PHP script
I have a multi-dimensional array right now that looks like this: function art_appreciation_feeds() {
Say you have the following ANSI C code that initializes a multi-dimensional array :
I have some code that creates a multi-dimensional array, but my result seems to
I have a returned multi dimensional array from my DB, looking something like this
I have a multi-dimensional array, which basically consists of one sub-array for each year.
I have a multi-dimensional array, no problem. How do I interrogator one of the
I have a multi dimensional array, like this: array('name' => array('title'=>'Title','date'=>'Created')) I store it
I have a multi dimensional array in PHP. $f = array('one' => array(*doesntmatter*), two

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.