blob: 5b6769b8d6229d60616594f325ac328935fc6796 [file] [log] [blame]
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +01001``column``
2==========
3
4The ``column`` filter returns the values from a single column in the input
5array.
6
7.. code-block:: twig
8
9 {% set items = [{ 'fruit' : 'apple'}, {'fruit' : 'orange' }] %}
10
11 {% set fruits = items|column('fruit') %}
12
13 {# fruits now contains ['apple', 'orange'] #}
14
15.. note::
16
17 Internally, Twig uses the PHP `array_column`_ function.
18
19Arguments
20---------
21
22* ``name``: The column name to extract
23
24.. _`array_column`: https://secure.php.net/array_column