Is there any simple way to compare two arrays.
ie; I have two arrays (a,b,c,d,e) and (b,c,d) after comparison I would like to get an array (a,e).
Could you clarify the requirements for the comparison? Don't answer for each of these, but instead define the criteria that covers all of them for the results you would want...
What if you have (b,c,d) and (a,b,c,d,e)?
What if you have (a,b,c,d,e) and (z,b,c,d,x)?
Actually I want to compare an array with another and get the first array after the common elements(common in two arrays) eliminated .
What if you have (b,c,d) and (a,b,c,d,e)? results --- null
What if you have (a,b,c,d,e) and (z,b,c,d,x)? results ---(a,e)
This is one way...
var array1:Array = new Array("a","b","c","d","e");var array2:Array = new Array("b","c","d");
var array3:Array = new Array();
for(var i:uint=0; i<array1.length; i++){ if(array2.indexOf(array1[i]) == -1){ array3.push(array1[i]); }}
trace(array3);
Thank you Ned Murphy
You're welcome
Thanks a ton!