View Full Version : Multidimensional arrays

10-17-2003, 11:11 AM
Basically I want to do this:

i = 14
myArray[i] = "hello";

... but with at multidimensional array.

I've tried:

i = 14
myArray[i].firstWord = "hello";
myArray[i].secondWord = "yo";

But no luck there...

What I have to do is change myArray[i].firstWord if it is different from some other word that I input - while running through a loop.

Well, that's what it boils down to. I you have the time you can have a look at the real codesnippet

// Find unique heights of all elements
for(i=0; i<_global.arrMagicElements.length; i++)
_global.arrMagicElementsUniqueHeights.push(_global .arrMagicElements[i].intElementHeight);
_global.arrMagicElementsUniqueHeights = _global.arrMagicElementsUniqueHeights.uniqueNum();

/* Make new array where all elements with unique heights are collapsed to one element with same dimensions combined*/

// Go through each found height
for(i = 0; i < _global.arrMagicElementsUniqueHeights.length; i++)
// Look through all original elements
for(y = 0; y < _global.arrMagicElements.length; y++)

// If heights are identical then collapse into new array
if (_global.arrMagicElementsUniqueHeights[i] == _global.arrMagicElements[y].intElementHeight)
_global.arrMagicElementsUniqueElements[i].intElementHeight = _global.arrMagicElements[y].intElementHeight;

Thanks in advance!

Billy T
10-17-2003, 01:10 PM

i = 14;
myArray[i]=new Array();
myArray[i]['firstWord'] = "hello";
myArray[i]['secondWord'] = "yo";


10-17-2003, 01:39 PM

i = 14;
myArray[i] = new Object();
myArray[i].firstWord = "hello";
myArray[i].secondWord = "yo";

10-20-2003, 06:22 AM
thanks for the response!

But it seems like

myArray[i].firstWord = "hello";

has to be defined before I can add/change it.

gawd I miss php arrays =)