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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:18:01+00:00 2026-06-15T09:18:01+00:00

The problem is similar to this Find an array inside another larger array The

  • 0

The problem is similar to this Find an array inside another larger array

The differences are that instead of searching for values, I’m searching for a small array key branch inside a larger array key tree.

Basically here’s the array key branch that I’m looking for:

$mission_parameters['stmt_echo']['subnodes']['exprs'][0]['expr_constfetch']['subnodes']['name']['name']['subnodes']['parts'][0] = 'true';

The array key tree is a very large tree which means it is multidimensional, and it may include $mission_parameters at any point in the tree.

So it’s kind of like trying to find a yellow tree branch in a brown tree which may or may not have a yellow tree branch.

Comparing the value at the end of the branch is also necessary.

I’m looking at array_intersect, but it doesn’t work on multidimensions. Has anyone solved this kind of problem before?

Note this is not the same as searching array within an array. I’m not searching values.

–EDIT–

Here’s an example:

I’m looking for

array(
    'statement' => array(
        'statement2' => array(
            0 => 'true',
        ),
    ),
);

Inside a larger array like this:

array(
    'statement4' => array(
        'statement' => array(
            'statement2' => array(
                0 => 'true',
            ),
            'statement3' => array(
                2 => 'false',
            ),
        ),
    ),
);

Do you see how the smaller array is like a branch to the larger array. The larger array currently contains the smaller branch, but it has other sorts of other elements. Therefore I’m searching an array key branch. In this example it would be [statement][statement2][0] = 'true'

  • 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-15T09:18:01+00:00Added an answer on June 15, 2026 at 9:18 am

    I think (and you have confirmed) that you can represent your data as an XML structure. I this case, you can use XPath to find any branch in your data. Here is sample XML data inferred from your question:

    <?xml version="1.0" encoding="utf-8" ?>
    <stmt_echo>
        <subnodes>
            <exprs>
                <expr_constfetch>
                    <subnodes>
                        <name>
                            <name>
                                <subnodes>
                                    <parts>
                                        <part>true</part>
                                        <!-- more items -->
                                    </parts>
                                </subnodes>
                            </name>
                        </name>
                    </subnodes>
                </expr_constfetch>
                <!-- more items -->
            </exprs>
        </subnodes>
    </stmt_echo>
    

    And here is the PHP code to locate the node you mentioned:

    $doc = new DOMDocument;
    $doc->Load("test.xml");
    
    $xpath = new DOMXPath($doc);
    $nodes = $xpath->query("//subnodes/parts[part='true']");
    
    foreach($nodes as $node) {
        dumpNodePath($node);
    }
    
    # Output
    # /stmt_echo/subnodes/exprs/expr_constfetch/subnodes/name/name/subnodes/parts
    
    function dumpNodePath($node) {
        $path = array($node->tagName);
        while ($node = $node->parentNode) {
            if ($node->nodeType != XML_DOCUMENT_NODE) {
                $path[] = $node->tagName;
            }
        }
        echo "/" . implode("/", array_reverse($path)) . "\n";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read similar questions to this problem but I couldn't find out why it
Similar to this question: link However I have already mastered that. My problem is
I have a similar problem to the one that is answered in this post
The problem is I have an array that has the key value pairs as
This problem is similar to when creating alternate colour table-rows, only we are dealing
my problem is a bit similar to this : I want to retrieve rows
I referred this on SO as the problem was similar to mine. In my
My example is similar to this - The only problem is I cannot rewrite
I have checked this similar question, but the suggestions did not solve my problem:
I have a cross-tab report which similar to this Problem is when there are

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.