Javascript:
function array_key_exists ( key, search ) { // Checks if the given key or index exists in the array
//
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// input sanitation
if( !search || (search.constructor !== Array && search.constructor !== Object) ){
return false;
}
return search[key] !== undefined;
}
Примеры:
array_key_exists('kevin', {'kevin': 'van Zonneveld'});
true
|
|
|
|