I am looking for how to trim each string in an array, in Craft 3.
I would like to check if a string is in an array of strings. The array is from a form submission, a checkbox group.
For example, there are two checkboxes and both of them are checked.
{% set array_checked_values = submission|split(',') %}
A: {{ array_checked_values[0] == "Value A" }}
B: {{ array_checked_values[1] == "Value B" }}
Although I do not know why, only A returns true, but B is false.
However, it returns true.
B': {{ array_checked_values[1]|trim == "Value B" }}
So, I need to trim each string in the array, but I do not know how to do that. None of these three method work.
{% set array_checked_values = submission|split(',')|trim %}
{% set array_checked_values = array_checked_values|trim %}
{% for val in array_checked_values %}
{% set val = val|trim %}
{% endfor %}