I think you should use isset() insteadof array_key_exists because with "array_key_exists" the value can be NULL, and the value must be defined