在Twig模板中{{in in ['a','b','99']}}返回1.为什么?

Question heading already asks it:

In a Twig template {{0 in ['a', 'b', '99']}} prints 1. WHY? I have '0' as a value and I can't check it against arrays, as that value always pops up as existing. And at the end of the day: How do I achieve the goal of checking zero against the array of strings, in Twig?

PHP's type coercion for comparisons goes to integers when necessary. You're checking if an integer is in the array. (int) 'a' is coerced to 0 for this comparison. So 0 is seen as being in the array.

To avoid this, you can use in_array with the strict option:

in_array('0', ['a', 'b', '99'], true)