intersect

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

{% set myPets = ['dog', 'cat', 'snake', 'elephant', 'fish'] %}
{% set yourPets = ['snake', 'camel', 'fish', 'shark'] %}
{% set samePets = myPets|intersect(yourPets) %}

{# samePets is ['snake', 'fish'] #}

Arguments

The intersect filter has the following signature.

intersect(array)
Argument Description
array

The array to intersect with the original value.

< Back to the list of filters