Here I have a problem corresponding to the SimpleXMLElement "name" attribute matching keys in an array. When I return the result of the attribute corresponding to the string key, invoking the array key, the result will be true, as expected. But when I try to give it a match using the in operator, the result will be false.
Twig:
{{ dump(options|keys) }}
{% for tense in verbXML %}
{{ dump(tense.attributes.name) }}
{{ dump(tense.attributes.name == (options|keys)[1]) }}
{{ dump(tense.attributes.name in options|keys) }}
{% endfor %}
Result:
array:2 [▼
0 => "neg-imperative"
1 => "present"
]
SimpleXMLElement {
+"0": "present"
}
true
false
source
share