Checks if the given key or index exists in the array