column

这个 column filter返回输入数组中单个列中的值。

1
2
3
4
5
{% set items = [{ 'fruit' : 'apple'}, {'fruit' : 'orange' }] %}

{% set fruits = items|column('fruit') %}

{# fruits now contains ['apple', 'orange'] #}

注解

在内部,Twig使用PHP array_column 功能。

争论

  • name :要提取的列名