Edit on GitHub
Jump to docs navigation

Twig Components / Methods / column

Note: You are currently reading the documentation for Bolt 5.0. Looking for the documentation for Bolt 5.2 instead?

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.