Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Comparing Multidimensional Arrays
Old 11-01-2008, 10:13 AM Comparing Multidimensional Arrays
Novice Talker

Posts: 9
Name: filippo
Trades: 0
Hello everybody,
I have two multidimensional arrays and I have to create a third one (for later use) from comparing these two. Here is my example code:
//BEGIN EXTEND SCRIPT/JAVASCRIPT CODE
var myGroups = [["00002","00003","00004","00005"],["00007","00008"],["00009","00010"]];
var myProducts = [["00002"],["00003"],["00007"],["00009"]];
var newGroups = new Array();
function main() {
for(i=0; i<myGroups.length; i++){
var myGroup = myGroups[i];
for(k=0; k<myGroup.length; k++){
for(j=0; j<myProducts.length; j++){
if(myProducts[j]==myGroup[k]){
newGroups.push(new Array(myProducts[j]));
}
}
}
}
alert (newGroups[0]);
}
main();
This way I get a third multidimensional array (newGroups) which contains 1 line arrays, while I want to maintain the grouping structure of the first multidimensional array ([["00002","00003"],["00007"],["00009"]]

Hope you understand the problem..
Any suggestions would be very appreciate
Thanks
filippo nanni is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to Comparing Multidimensional Arrays
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19201 seconds with 12 queries