In PHP we can check if a key exists in an array by using the function array_key_exists().
In the Twig templating language we can check if an variable or
default filter.default filter.default filter.default filter catches any exceptions owing to undefined variable, and allows short-circuit substition of an alternate value.default filter is chainable.
{#- ****************************************
testing for a single key in associative array
-#}
{%- set mystring = myarray['key-no-existo'] |default('__BLANK__') -%}
{#- ****************************************
testing for a multiple keys in associative array
-#}
{%- set mystring = myarray['alpha']
|default(myarray['bravo'])
|default(myarray['charlie'])
|default('__BLANK__')
-%}