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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:38:16+00:00 2026-06-03T18:38:16+00:00

I have here a nested multidimensional array: Array ( [merchant] => Array ( [XML_Serializer_Tag]

  • 0

I have here a nested multidimensional array:

Array
(
[merchant] => Array
    (
        [XML_Serializer_Tag] => Array
            (
                [id] => 736
                [name] => Cadbury Gifts Direct
            )

        [prod] => Array
            (
                [XML_Serializer_Tag] => Array
                    (
                        [0] => Array
                            (
                                [XML_Serializer_Tag] => Array
                                    (
                                        [id] => 88966064
                                        [pre_order] => no
                                        [web_offer] => no
                                        [in_stock] => no
                                        [stock_quantity] => 0
                                    )

                                [pId] => 608
                                [isbn] => 0000000000000
                                [text] => Array
                                    (
                                        [name] => 50% OFF 56g Creme Egg Minis
                                        [desc] => 50% OFF Creme Egg Minis in a 56g bag.
                                    )

                                [uri] => Array
                                    (
                                        [awTrack] => http://www.awin1.com/pclick.php?p=88966064&a=67702&m=736
                                        [awThumb] => http://images.productserve.com/thumb/736/88966064.jpg
                                        [awImage] => http://images.productserve.com/preview/736/88966064.jpg
                                        [mLink] => http://www.cadburygiftsdirect.co.uk/products/608-50-off-56g-creme-egg-minis.aspx
                                        [mImage] => http://www.cadburygiftsdirect.co.uk/images/thumbs/0001084.png
                                    )

                                [price] => Array
                                    (
                                        [XML_Serializer_Tag] => Array
                                            (
                                                [curr] => GBP
                                            )

                                        [buynow] => 0.31
                                        [store] => 0.00
                                        [rrp] => 0.00
                                        [delivery] => 0.00
                                    )

                                [cat] => Array
                                    (
                                        [awCatId] => 437
                                        [awCat] => Chocolate
                                        [mCat] => Full Range
                                    )

                                [brand] => 
                                [valFrom] => 0000-00-00
                                [valTo] => 0000-00-00
                                [comAmount] => 0.00
                            )

The segment loop afterwards.

So…

[1] => Array
[2] => Array
[3] => Array

etc…

I need to find the names of the attributes of each array segment.

So I have used this recursive loop:

private function recursive_array($old_array, $new_array = array()) {

    foreach ($old_array as $key => $value) {

        if (is_array($value) && $key < 1) {
            $new_array = $this->recursive_array($value, $new_array);

        } else {
            if ($key < 1) {
                $new_array[] = $key;

            }
        }
    }
    return $new_array;
}

This is the output:

array
  0 => string 'id' (length=2)
  1 => string 'name' (length=4)
  2 => string 'id' (length=2)
  3 => string 'pre_order' (length=9)
  4 => string 'web_offer' (length=9)
  5 => string 'in_stock' (length=8)
  6 => string 'stock_quantity' (length=14)
  7 => string 'pId' (length=3)
  8 => string 'isbn' (length=4)
  9 => string 'name' (length=4)
  10 => string 'desc' (length=4)
  11 => string 'awTrack' (length=7)
  12 => string 'awThumb' (length=7)
  13 => string 'awImage' (length=7)
  14 => string 'mLink' (length=5)
  15 => string 'mImage' (length=6)
  16 => string 'curr' (length=4)
  17 => string 'buynow' (length=6)
  18 => string 'store' (length=5)
  19 => string 'rrp' (length=3)
  20 => string 'delivery' (length=8)
  21 => string 'awCatId' (length=7)
  22 => string 'awCat' (length=5)
  23 => string 'mCat' (length=4)
  24 => string 'brand' (length=5)
  25 => string 'valFrom' (length=7)
  26 => string 'valTo' (length=5)
  27 => string 'comAmount' (length=9

What it is also picking up is the top nested array:

[XML_Serializer_Tag] => Array
            (
                [id] => 736
                [name] => Cadbury Gifts Direct
            )

This is just details for the entire feed not the individual segments.

I need a way of filtering out the top nested array but bear in mind that the details are dynamic so the name of the keys can change from one feed to the next

  • 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-03T18:38:21+00:00Added an answer on June 3, 2026 at 6:38 pm

    Maybe this?

    $riter = new RecursiveIteratorIterator(New RecursiveArrayIterator($array));
    foreach ($riter as $key => $val) {
        if ($riter->getDepth() > 1) {
            echo "$key => $val\n";
        }
    }
    

    by default, RecursiveIteratorIterator only visits leaf nodes(the deepest levels down every path). getDepth() can be used to make sure were a minimum depth. I’m not sure if 1 is the correct number, but anyway…

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

Sidebar

Related Questions

I can't figure out what is going on here. I have some nested lists
This is my first question here :) I have an array with a number
I have a nested repeater control. Here is what the HTML looks like: <ItemTemplate>
I have a problem with bounded nested wildcards in Java generics. Here's a common
I have a nested Javascript object like var data = { 'name': { 'heading':
I have a tricky CSS situation here. Basically I have nested span tags that
I have read quite a few posts here for matching nested braces in Ruby
I have the same problem outlined here . That is, nested view models in
What I'm talking about here are nested classes. Essentially, I have two classes that
beginner to python here. I have 2 nested lists that I want to merge:

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.