in_array function in javascript

function in_array( what, where ){
var a=false;
for(var i=0;i
if(what == where[i]){
a=true;
break;
}
}
return a;
}

Example:

var itemArray = new Array();

if (in_array(‘search item’,itemArray))
{
alert(‘item exists’);
}

Advertisements