# Searching within an Array

**URL:** <https://forum.kirupa.com/t/searching-within-an-array/76725>\
**Category:** Uncategorized\
**Created:** [January 20, 2005, 10:36pm UTC](https://forum.kirupa.com/t/searching-within-an-array/76725 "2005-01-20T22:36:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jc\_](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@jc\_](https://forum.kirupa.com/u/jc_)\
**Post date:** [January 20, 2005, 10:36pm UTC](https://forum.kirupa.com/t/searching-within-an-array/76725/1 "2005-01-20T22:36:51Z")

</div>

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:

```auto
// 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:

```auto
myArray = ["Betty Davis", "Team Macromedia", "Houston Soccer Team"]; 

```

\*\*How would I find all array items that match “Team”? \*\* :book:

Your help would be greatly appreciated.

Regards,  
jc\_
