Jump to content

ARRAY Objects


Lefu

Recommended Posts

hello guys,

 

I have an array like

var letters = new Array('a',...,'i');

then I have created arrays dynamically like

var pgA= new Array('a1','a2');

var pgB= new Array('b1','b2');

and so on untill pgZ = new Array('z1','z2');

I want to have a loop like

for (i = 0; i<9; i++)

{

  alert('pg'+toUpperCase(letter));

}

output is "pgA" not the contents.

 

I want to work with arrays in the pgA .. pgZ

 

without having to write pgA to pgZ manually in their own separate loops.

Thank you for you help and I hope you understand what I wanna do here.

 

Link to comment
https://forums.phpfreaks.com/topic/161906-array-objects/
Share on other sites

first...instead of having separate variables, let's utilize JSON:

 

var pg = {
  'A' : [ 'a1', 'a2' ],
  'B' : [ 'b1', 'b2' ]
};
alert(pg['A']);

 

you can also automate the filling of the array. but, what exactly are you trying to accomplish...you might be able to do this without building that massive object

Link to comment
https://forums.phpfreaks.com/topic/161906-array-objects/#findComment-854395
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.