hello all,
quick lil question…
I’m trying to fugure out the best approach to to search within items in an array…
Here some sample code I use for basic (single item) search:
// Create an array with eight elements.
myArray = ["a", "b", "c"];
// Specify what we want to search for.
searchString = "b";
// Use a for statement to loop through, potentially, all the elements of the array.
for (var i = 0; i < myArray.length; i++) {
// Check whether the current element matches the search value.
if (myArray* == searchString) {
// Do something with the matching element, if necessary. In this example, display
// a message in the Output window for testing purposes.
trace("Element with index " + i + " found to match " + searchString);
// Include a break statement to exit the for loop once a match has been found.
break;
}
}
Ok, so what if I wanted to search for a Word among multiple words.
For example, how would I find out if the array finds a match within an array such as:
myArray = ["Betty Davis", "Team Macromedia", "Houston Soccer Team"];
**How would I find all array items that match “Team”? **
Your help would be greatly appreciated.
Regards,
jc_