Is in_array or similar possible within an if statement?
You just have to change the second line of your second code-block from: {% if myVar is in_array(array_keys(someOtherArray)) %} # or {% if myVar in someOtherArray|keys %} in is the containment-operator, and keys, is a filter that returns an arrays keys.