Edit on GitHub
Jump to docs navigation

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'] #}


Internally, Twig uses the PHP array_column function.


  • 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.