# Creating a random map into an array

**URL:** <https://forum.kirupa.com/t/creating-a-random-map-into-an-array/234341>\
**Category:** flash\
**Created:** [August 1, 2007, 2:33pm UTC](https://forum.kirupa.com/t/creating-a-random-map-into-an-array/234341 "2007-08-01T14:33:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hatu](https://avatars.discourse-cdn.com/v4/letter/h/f04885/32.png) [@hatu](https://forum.kirupa.com/u/hatu)\
**Post date:** [August 1, 2007, 2:33pm UTC](https://forum.kirupa.com/t/creating-a-random-map-into-an-array/234341/1 "2007-08-01T14:33:42Z")

</div>

I’m trying to create a program that creates a random map for a side scrolling cave.  
So I need to store the roof and the grounds y coordinate into a big array, like 10 000 pieces of wall.

The only way I’ve gotten it to accept some data into the array is like this but I want something cleaner and something that can go on forever.

How should I format the first 4 lines of code so that the array accepts commands like this and expands for the for loop as needed?  
level\*[j] = something;

```php
var level = [ 
["0","0","0","0","0","0"],//this will be the roof 
["0","0","0","0","0","0"]//this will be the ground 
]; 
//need something better for the code above

for (i=0;i<10;i++){ 
    for (j=0;j<2;j++){ 

        level[j]* = 1; 
    } 
     
} 

for (i=0;i<10;i++){ 
    for (j=0;j<2;j++){ 

        trace(j + "j i" + i +"-" + level[j]*); 
    } 
     
}  

```
