phppup Posted August 26, 2022 Share Posted August 26, 2022 (edited) 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 August 26, 2022 by phppup Forgot item Quote Link to comment https://forums.phpfreaks.com/topic/315240-building-multidimensional-array/ Share on other sites More sharing options...
gw1500se Posted August 26, 2022 Share Posted August 26, 2022 Are you trying to get 3 levels deep? myArr[0][0][0] Quote Link to comment https://forums.phpfreaks.com/topic/315240-building-multidimensional-array/#findComment-1599856 Share on other sites More sharing options...
phppup Posted August 26, 2022 Author Share Posted August 26, 2022 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? Quote Link to comment https://forums.phpfreaks.com/topic/315240-building-multidimensional-array/#findComment-1599857 Share on other sites More sharing options...
Barand Posted August 26, 2022 Share Posted August 26, 2022 1 hour ago, phppup said: Shouldn't those be the first values at each level? Yes. But if the first element, $myarray[0], is an array, print_r() is going to say array. Why would you expect different? Quote Link to comment https://forums.phpfreaks.com/topic/315240-building-multidimensional-array/#findComment-1599860 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.