The array_key_exist method can be used to validate is a key exist with an array. The result is true if the key is found and false if the key does not exist.

array_key_exist

{{"text"|array_key_exist:$array}}

Examples

Examples

{{$array = ["Newsletter" => "1", "Service email" => "0", "Review email" => "1"]}}


{{if "Newsletter"|array_key_exist:$array && $array['Newsletter'] eq 1}}
  The customer is subscribed to the newsletter!
{{else}}
   Sadly no newsletter subscription
{{/if}}

Outcome:

 The customer is subscribed to the newsletter!