in_array -- 检查数组中是否存在某个值
说明
bool in_array ( mixed needle, array haystack [, bool strict] )
在 haystack 中搜索 needle,如果找到则返回 TRUE,否则返回 FALSE。
function in_array(needle, haystack) {
if(typeof needle == 'string' || typeof needle == 'number') {
for(var i in haystack) {
if(haystack[i] == needle) {
return true;
}
}
}
return false;
}