I just run weird behavior in a branch.
I just used for()an array that does not have any keys installed, except the one that was added to the array before. For test cases, just assume this php array is:
$array = array (
0 => 'test1',
1 => 'test2',
'someKey' => 'test3'
)
So, I did this in a branch:
{% for key, value in array %}
{% if key == 'someKey' %}
{{ 'something special happend' }}
{% else %}
{{ 'how boring' }}
{% endif %}
{% endfor %}
What completely engulfed me was the fact that it something special happendwas named twice .
After some searching, I found that this case also applies to the key 0.
So, I tried the following:
{{ dump (key == 'someKey') }}
The result was
So, I did another test:
{{ dump(key|lower == 'somekey') }}
The result was
Since I wanted to be sure, this was my last test.
{{ dump(0 == 'somekey') }}
{{ dump(0|lower == 'somekey') }}
The result was
Why does this behavior look like this? I can not explain it.
PS: , , , , , .