Answers for "filter twig"

PHP
0

twig filter array

{% set sizes = {
    xs: 34,
    s:  36,
    m:  38,
    l:  40,
    xl: 42,
} %}

{% for k, v in sizes|filter((v, k) => v > 38 and k != "xl") %}
    {{ k }} = {{ v }}
{% endfor %}
{# output l = 40 #}
Posted by: Guest on July-22-2021
0

twig filter

{% set sizes = [34, 36, 38, 40, 42] %}

{{ sizes|filter(v => v > 38)|join(', ') }}
{# output 40, 42 #}
Posted by: Guest on October-13-2021
0

twig filter array

{% set sizes = {
    xs: 34,
    s:  36,
    m:  38,
    l:  40,
    xl: 42,
} %}

{% for k, v in sizes|filter((v, k) => v > 38 and k != "xl") %}
    {{ k }} = {{ v }}
{% endfor %}
{# output l = 40 #}
Posted by: Guest on July-22-2021
0

twig filter

{% set sizes = [34, 36, 38, 40, 42] %}

{{ sizes|filter(v => v > 38)|join(', ') }}
{# output 40, 42 #}
Posted by: Guest on October-13-2021

Browse Popular Code Answers by Language