Frequently Asked Questions > Practical Questions > Working with MAXScript Values >

# How do I create a multi-dimensional array?

MAXScript FAQ > MAXScript Values > How do I create a multi-dimensional array?

A MAXScript Array is a one-dimensional list of elements. An element of an array is addressed by its index in brackets,

FOR EXAMPLE
    myArray = #(10,20,30,40,50,60,70,80,90,100)
    myArray[5] --> will return 50, the fifth element of the array.

Since an array can be an element inside of another array, you can create multi-dimensional arrays as you desire by placing multiple arrays inside an array. Using an index in brackets, you can reference the sub-array, using another pair of brackets and an index you can access an element inside the sub-array,

FOR EXAMPLE
     -- create an array with two elements, each one an array with 10 elements.
    myMultiDimArray=#(#(1,2,3,4,5,6,7,8,9,10),#(10,20,30,40,50,60,70,80,90,100))
    -- add a third element to the array containing 10 more elements
    append myMultiDimArray #(100,200,300,400,500,600,700,800,900,1000)
    myMultiDimArray[2][5]--> returns 50 - the 5th element of the 2nd sub-array

#### See Also

- Array Values

- What is the differences between Arrays and BitArrays?

- Frequently Asked Questions