Twig {% if myId in myArray %} not checking for unique values? -
i have id need check against array of ids.
when this:
{% if myid in myarray %} it works if i'm checking '10' in array of '10,'11','12'. however, if check '1' in same array of '10','11','12', results in true since '1' present in values listed ('0' or '2' result true in case). i'm wanting result false since exact integer '1' not present in array.
is there way have twig check unique or exact integer values when using function?
as maerlyn pointed out source code on in keyword of twig, visible problem caused values being strings.
indeed twig considers '1' present in '12' because doesn't know '12' integer, contrain 'number1' or other string.
so solution convert array contents integers first. send twig.
Comments
Post a Comment