Checks if a value exists in an array