Get a Demo
Table of contents

intersect Twig Filter

The intersect filter returns an array containing only the values that are in both arrays.

This filter is unique to Aptuitiv. It is not part of the core Twig functionality.
{% set myPets = ['dog', 'cat', 'snake', 'elephant', 'fish'] %}
{% set yourPets = ['snake', 'camel', 'fish', 'shark'] %}
{% set samePets = myPets|intersect(yourPets) %}
{# samePets is ['snake', 'fish'] #}

Arguments Link

The intersect filter has the following signature.

intersect(array)
Argument Description
array The array to intersect with the original value.
Get Started With Aptuitiv