Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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 #}
Source by twig.symfony.com #
 
PREVIOUS NEXT
Tagged: #twig #filter #array
ADD COMMENT
Topic
Name
3+2 =