- Home /
Search an array?
Hi all,
For example, I have an array with many integers and i need to search one of the integer. Could someone help?
Thanks in advance
Answer by Alec-Slayden · Feb 29, 2012 at 09:29 AM
Well all elements of an array have an index associated, so Fu[0] would be the first value of array "Fu", and Fu[1] the second, etc. So you can just iterate through those. If your array is Fu, and the int you're looking for is Bar, An example might be:
var n : int = 0;
for (n = 0; n < Fu.length; n++){ if ( Fu[n] == Bar ) DoSomething(); }
that should be Fu.length; editted but not refreshing properly just yet :P
Answer by Eric5h5 · Feb 29, 2012 at 10:28 AM
var numbers = new int[500];
numbers[456] = 7;
if (7 in numbers) print ("Oh, look, a 7!");
Your answer
Follow this Question
Related Questions
How do I sort floats by highest to lowest value? 1 Answer
I want some ints stored in a new int right after eachother 1 Answer
Array in an array? 2 Answers
bool[string] = true; array possible? 2 Answers
Find Highest Value in Array 5 Answers