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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:51:42+00:00 2026-06-03T09:51:42+00:00

I have nested structure very similar to folder structure, like: Array ( [level_one_1] =>

  • 0

I have nested structure very similar to folder structure, like:

Array
(
    [level_one_1] => Array
        (
            [level_two_1] => value1
            [level_two_2] => valuetwo
            [level_two_3] => value_three
        )
    [level_one_2] => Array
        (
            [level_two_4] => value1
            [level_two_5] => valuetwo
            [level_two_6] => value_three
        )
    [level_one_3] => Array
        (
            [level_two_2] => valuetwo
            [level_two_3] => value_three
        )
)

Is it a quick way to covert it to something like this:

Array
(
    [level_one_1/level_two_1] => value1
    [level_one_1/level_two_2] => valuetwo
    [level_one_1/level_two_3] => value_three

    [level_one_2/level_two_4] => value1
    [level_one_2/level_two_5] => valuetwo
    [level_one_2/level_two_6] => value_three)

    [level_one_3/level_two_2] => valuetwo
    [level_one_3/level_two_3] => value_three
)

Slash between levels would be separator – it could anything. Also it would be dynamic numbers of levels.

Is it a way to do so by using predefined array* functions ? with recursion ?

  • 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-03T09:51:43+00:00Added an answer on June 3, 2026 at 9:51 am

    Something like this. Untested, but should help you get started in the right direction:

    $myArray = array(
    'level_one_1' => array(
            'level_two_1' => 'value1',
            'level_two_2' => 'valuetwo',
            'level_two_3' => 'value_three'
    ),
    'level_one_2' => array(
            'level_two_4' => 'value1',
            'level_two_5' => 'valuetwo',
            'level_two_6' => 'value_three'
    ),
    'level_one_3' => array(
            'level_two_2' => 'valuetwo',
            'level_two_3' => 'value_three'
    ));
    $ritit = new RecursiveIteratorIterator(new RecursiveArrayIterator($myArray));
    $result = array();
    foreach ($ritit as $leafValue) {
        $keys = array();
        foreach (range(0, $ritit->getDepth()) as $depth) {
            $keys[] = $ritit->getSubIterator($depth)->key();
        }
        $result[ join('/', $keys) ] = $leafValue;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very nested entity structure like this: DataObject > Universities (List) >
I have a structure that can be very easily represented using a three-deep nested
So I have a nested div structure and I would like to get the
Suppose I have a nested structure, something like this: {:data1 {:categories [ {:name abc
In Perl, when you have a nested data structure, it is permissible to omit
Hi currently I have a nested XMl , having the following Structure : <?xml
I have nested iframes and I would like to use onload function for the
I have two nested loop in XSL like this, at this moment I use
I have a table structure like below : categoryID bigint , primary key ,
I have a nested structure as follows: typedef struct { float mz_value; float int_value;

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.