column
column
过滤器从输入数组中的单列返回数值。
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
: 要提取的列名