# Help creating 2D Array in a for loop

**URL:** <https://forum.kirupa.com/t/help-creating-2d-array-in-a-for-loop/310591>\
**Category:** flash\
**Created:** [June 14, 2010, 2:41pm UTC](https://forum.kirupa.com/t/help-creating-2d-array-in-a-for-loop/310591 "2010-06-14T14:41:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![humbucker](https://avatars.discourse-cdn.com/v4/letter/h/278dde/32.png) [@humbucker](https://forum.kirupa.com/u/humbucker)\
**Post date:** [June 14, 2010, 2:41pm UTC](https://forum.kirupa.com/t/help-creating-2d-array-in-a-for-loop/310591/1 "2010-06-14T14:41:05Z")

</div>

Hi!

I will do my best to explain in a simple way what I’m trying to achieve.

I must create a 2D array from an XML file that looks like this

\<pic\>  
\<sectionName\>\</sectionName\>  
\<img\>\</img\>  
\</pic\>

\<pic\>  
\<sectionName\>\</sectionName\>  
\<img\>\</img\>  
\<img\>\</img\>  
\<img\>\</img\>  
\</pic\>

As you can see for ONE sectionName there can be one or more IMG.

What I d’like to end up with is an Array that look like this

ID  
0  
sectionName0  
pic0

ID  
1  
sectionName1  
pic1

ID  
2  
sectionName1  
pic2

ID  
3  
sectionName1  
pic3

…

Because I need to be able to know which picture belong to which sectionName.

```auto

totalpic = myXML.pic.length();
        
        for(var i:int = 0; i < totalpic; i++){

            myAlbumArray* = myXML.pic.img.text()*;
        }

```

Can you tell me how to add the 2D array right in the loop?

Thanks a LOT!
