-
How can i delete Duplicates in an Array ?
Hi !!!
I was hoping someone could spare me a minute and help me with the problem im having. Probably a no-brainer, but unfortunately thats my problem..no brain
Ive populated an array with some data from sql, and would love to delete all the duplicates...etc:
[0] = 11111
[1] = 11111
[2] = 22222
[3] = 22222
[4] = 33333
Ive tried all sorts of things to no avail, anyone got any ideas ?
Many many thanks,
Loomy
-
Uses MX 2004 Pro
Hi,
Maybe something like this will do the trick...
Code:
var a:Array = [1111, 5555, 1111, 3333, 1111, 3333, 6666, 2222, 2222, 4444];
for (var i in a) {
for (var j in a) {
if (a[i] == a[j] and i != j) {
a.splice(Number(j), 1);
}
}
}
trace(a);
-
Banned
Hi,
Here is another option....
Remove duplicates...
code:
things = ['Rock', 'Door', 'Stone', 'Door', 'Car', 'Dog'];
temp = {};
for (var i in things) {
temp[things[i]] = 1;
}
things = [];
for (var i in temp) {
things.push(i);
}
trace(things);
-
Thanks a million peeps !!! really appreciate it gonna try em both out
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|