Jump to content

Building multidimensional array


phppup

Recommended Posts

I'm trying to build an array as follows:

Level 1

Level 2

Level 3

Examples seem to be showing similar implementation to this

$myArr = array( 'level 1',
          array('level 2' ),
    array(
    array( 5, 6 ),
    array( 7, 8 )
  )
);

But this seems to move the data one section deeper than necessary.

In other words, there is nothing at position [0][0] or [0][0][0] (except Array which pushes me down another level).

Shouldn't my access to the first item on level 1 be $myArr[0]?

How can I get this lined up accordingly?

 

Edited by phppup
Forgot item
Link to comment
Share on other sites

I am trying to establish an array that will be the levels deep.

I want to access all data, but for some reason arrays keep moving to position 1 or more.

I want to be able to establish a value at [0], at [0][0], and also [0][0][0]

Shouldn't those be the first values at each level?

How do I set this up?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.