-3

I want to make a array of arrays. Problem: My final array will be like this:

 Array(Array1, Array2, Array3);
     and arrays will be 
 Array1=Array ( [0] => 0 [1] => 100 [2] => 100 [3] => 0 [4] => 0 [5] => 0 [6] => 0
 Array2=Array ( [0] => 0 [1] => 100 [2] => 100 [3] => 60 [4] => 0 [5] => 30 [6] => 0
 Array3=Array ( [0] => 50 [1] => 100 [2] => 100 [3] => 0 [4] => 0 [5] => 0 [6] => 40

So how can make the multidimensional array and how can I access data from this array. Help will be appreciated. Thanks

3

1 Answer 1

0

Unlike a statically typed language, there is no need to declare these up front which can be confusing to newcomers. Really what you're describing is just a two-dimensional array. So really you have two options. Assuming these aren't associative like your example above, either putting arrays together:

$array = array($array1, $array2, $array3);

Or if you are doing something with loops/iterators you can just define your two-d array on the fly:

$array[$itr][$inner_itr] = $array1[$inner_itr];

Hope that helps.

Sign up to request clarification or add additional context in comments.

1 Comment

Thnaks @Derek Dowling

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.