Twig Components / Methods / column
column
is a Twig filter to return the values from a single column in the input array.
{% set items = [{ 'fruit' : 'apple'}, {'fruit' : 'orange' }] %}
{% set fruits = items|column('fruit') %}
{# fruits now contains ['apple', 'orange'] #}
Note¶
Internally, Twig uses the PHP array_column function.
Arguments¶
- name: The column name to extract
Source: Twig
Edit this page on GitHub
Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on Github.
Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on Github.