PDA

View Full Version : Array Is In



A7RSTR7K3
March 26th, 2005, 08:29 PM
Hey All...
Well I know I should probably know this, but I don't I need to know is there some kind of isIn for an array. To test if an item is an element in an array. I just cant remeber what it is. Thnx.

stwingy
March 26th, 2005, 08:45 PM
Hey All...
Well I know I should probably know this, but I don't I need to know is there some kind of isIn for an array. To test if an item is an element in an array. I just cant remeber what it is. Thnx.

for (i=0; i<myArray.length; i++) {
if (myArray[i] == whatever) {
trace("my item found!");
break;
}
}

A7RSTR7K3
March 26th, 2005, 09:07 PM
is there a built in funciton to do this? I know I can write a way to test it... but is there anything built in which supports it?

stwingy
March 27th, 2005, 02:41 AM
is there a built in funciton to do this? I know I can write a way to test it... but is there anything built in which supports it?

No, i don`t think they have made your "is in" function yet.
BTW-this is only checking to see if your value exists within an array, there may be several elements containing the same value.

A7RSTR7K3
March 27th, 2005, 12:38 PM
So is there really no is in function? Anyone know of a built in work around? thanks stwingy... I'm using that right now just wonderin cuz built in things are usually faster.

amnos
March 27th, 2005, 11:55 PM
There is no built in way as Stwingy said, what he showed you is how we all search an array in the simplest form, well atleast me.