Preventing error Undefined variable $hashes when array_key_exists runs