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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:06:16+00:00 2026-05-29T15:06:16+00:00

Hy, I have a very big question . I have an array like this

  • 0

Hy,

I have a very big question .
I have an array like this one $array[0] = 12, $array[1] = 20, $array[2] = 18 and based on this array i want to give a value to this array $array_go[12][20][18] = $value because i’m building a recursive function to create a multidimensional array with lots of subarrays.

Thank you very much .

P.S. : Is it more simple if I have a $variable = '[12][15][20]'; and somehow to create $array{$variable} = value ; because i can't seem how to do it ?

  • 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-29T15:06:17+00:00Added an answer on May 29, 2026 at 3:06 pm

    To be honest, I can’t really follow what you’re asking as I think there is a lot of unneeded information obscuring your actual question.

    For starters, you can try the following code:

    function helper(&$array, $path, $value) {
      $parent =& $array;
      foreach ($path as $entry) {
        if (!isset($parent[$entry])) {
          $parent[$entry] = array();
        }
    
        $parent =& $parent[$entry];
      }
    
      $parent = $value;
      // make this $parent[] if more than
      // one $value will be added to the same path
    }
    
    $array_go = array(); // or use some other array you already have
    helper($array_go, array(12, 20, 18), 1);
    helper($array_go, array(12, 15, 20), 2);
    helper($array_go, array(12, 10, 22), 3);
    
    print_r($array_go);
    
    
    /*
    Array
    (
        [12] => Array
            (
                [20] => Array
                    (
                        [18] => 1
                    )
    
                [15] => Array
                    (
                        [20] => 2
                    )
    
                [10] => Array
                    (
                        [22] => 3
                    )
    
            )
    
    )
    */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all, I want to say sorry for this very big question, but
I have a very big constant array that is initialized at compile time. typedef
I have very simple select like this: SELECT * FROM table WHERE column1 IN
I have a very large array of doubles that I am using a disk-based
I have this data which can be very big in size, this could be
I have some very big delimited data files and I want to process only
I have this on a very big number of pages: src=//avatar/images/...; this server is
I have a very big file 4GB and when I try to read it
I have a very big problem. I am making a CRM (Costumer Relationship Management)
I have always been a very big fan of the DHTML calendar http://www.dynarch.com/projects/calendar/ I

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.