View Full Version : How to browse a 2 dimensions associatif Array ?

04-12-2005, 06:27 PM

I load a 2 dimensions javascript Array from an API. Let's say the array is called tab_int.
So, first, there are declarations like :
tab_int new = Arrray() ;
tab_int['x'] = new Array() ;

So I mean that :
_ tab_int['x'] is an associatif Array
_ tab_int is a 2 dimensions array - and even 2 dimensions associatif, because of the way I use it ...
So there are some functions using this tab without problems with some tab_int['x']['z'] - actually 'x' and 'z' are in variables most part of the time

Apart from one function ... of course (!), the function where I need to browse the entire table :

for ( var myInt in tab_int['x'] ) {
if (tab_int['x'][myInt] != '' ) {
// processing
I have some really funny results, not stable, not secure, which makes me wonder if I'm on the good way !
Sometimes I can go inside the loop (the first time, for example) but then I can't ... ?
So : does that work ? is there something to re-initialize ? does anyone of you can make this kind of things work ?

Thank you by advance for any clue ...

04-12-2005, 11:51 PM
Just be sure to realize the distinction between setting array properties and nesting arrays... tab_int['x'] becomes a property of tab_int, rather than an array item.

04-13-2005, 05:08 PM
oh yes ! you're right the "for ... in" has to be used with objects, but I thought it could be one way to go around this difficulty : how can I make to browse an associatif Array, how ever be the dimension of this array ?
Thank you by advance

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum