Php – In a Twig template, how can I group items in an array by the value of a property of an item?
In PHP I would do this: $menu_groups = array(); foreach($items as $item){ $menu_id = $item['properties.menu_id']; if(!array_key_exists($menu_id, $menu_groups)) $menu_groups[$menu_id] = array(); $menu_groups[$menu_id][] = $item; } How can I accomplish something similar in a Twig template?