In PHP, monster[pid][id2]['db_id'] will create the intermediate arrays (monster[pid] and monster[pid][id2]) if they don't already exist. Javascript isn't that smart, and monster = [[[]]] doesn't help. You'll have to do something like: monster[pid] = monster[pid] || []; monster[pid][id2] = monster[pid][id2] || {}; // I'm using {} rather than [] since you're using a string to access it, not a number monster[pid]pid2]['db_id'] = $(this).find('db_id').text();
Inconvenient, but I don't know a way around it. On Mar 29, 12:04 pm, Tadas J <[EMAIL PROTECTED]> wrote: > Hello, > > I have a problem with arrays. I am getting data from xml and trying to > get data to arrays. Here is my code: > > =============================== > var monster = [[[]]]; > ... > $(this).find('monsters').each(function(id2){ > monster[pid][id2]['db_id'] = $(this).find('db_id').text();}); > > ... > =============================== > > When I am alerting the variable it alerts only the first value and > then stops and in firebug I see this error: > > ==================== > monster[pid][id2] has no properties > [Break on this error] monster[pid][id2]['db_id'] = $ > (this).find('db_id').text(); > ==================== > > Maybe I have wrongly defined monster variable?