# Search in array

**URL:** <https://forum.kirupa.com/t/search-in-array/287287>\
**Category:** Uncategorized\
**Created:** [April 29, 2009, 6:56am UTC](https://forum.kirupa.com/t/search-in-array/287287 "2009-04-29T06:56:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel\_mihalcea](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@daniel\_mihalcea](https://forum.kirupa.com/u/daniel_mihalcea)\
**Post date:** [April 29, 2009, 6:56am UTC](https://forum.kirupa.com/t/search-in-array/287287/1 "2009-04-29T06:56:30Z")

</div>

Hello there. I have this function, searchCout:  
var array:Array = [“a”, “b”, “c”, “a”, “3”, “c”, “7”, “q”, “q”, “1”, “3”, “c”, “c”];

function searchCount(wor, arr){  
var counter = 0;  
for(i=0; i\<arr.length; i+=1){  
if(arr\*==wor){  
counter+=1;  
}  
}  
return counter;  
}

for (k=0; k\<array.length; k++) {  
trace(k+"="+searchCount(array[k], array));  
}

And I have this little problem. In my scenario I have 2 arrays itemArray and quantityArray. The problem is like this. I call this function and verifie if I have the same elements in itemArray, if so I add the number of the same elements in the quantityArray, in his position. How can I do that? Eny sugestions?  
Thank you.
