# Comparing two arrays, checking for matching values

**URL:** <https://community.hubspot.com/t/comparing-two-arrays-checking-for-matching-values/25055>\
**Category:** CMS Development\
**Tags:** design-manager\
**Created:** [September 4, 2020, 10:07am UTC](https://community.hubspot.com/t/comparing-two-arrays-checking-for-matching-values/25055 "2020-09-04T10:07:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amit\_95](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/amit_95/32/74736_2.png) [@Amit\_95](https://community.hubspot.com/u/Amit_95)\
**Post date:** [September 4, 2020, 10:07am UTC](https://community.hubspot.com/t/comparing-two-arrays-checking-for-matching-values/25055/1 "2020-09-04T10:07:43Z")

</div>

I have a repeater field which allows user to add text.

I’ve created an array which stores all these repeater values into an array called topics.

```lia-code-sample
{% set topics = [] %}

<!-- append topics from repeater to array -->
{% for item in module.add_topics.topics %}
 {% set topic_option = item|striptags %}
 {% do topics.append( topic_option ) %}
{% endfor %}

<!-- dumping data 
{{ topics }}

[Data, Accounting, Insight]
--> 

```

The above is basically a predefined list. I now want to compare values in the above array to all blog tags that exist.

Demo:

```lia-code-sample
{% set all_tags = blog_topics('default' , 250) %}

{{ all_tags }}

<!-- above prints: [Accounting, Press, Data] -->

```

So from the above two arrays, Data and Accounting are in both. I now want to create another array which has these matching values.

How can I go about this?

---

<div class="post-metadata">

**Author:** ![sharonlicari](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sharonlicari/32/101479_2.png) [@sharonlicari](https://community.hubspot.com/u/sharonlicari)\
**Post date:** [September 7, 2020, 9:55am UTC](https://community.hubspot.com/t/comparing-two-arrays-checking-for-matching-values/25055/2 "2020-09-07T09:55:50Z")

</div>

Hey [@Amit\_95](https://community.hubspot.com/t5/user/viewprofilepage/user-id/64311)

Thank you for sharing this. I’ll tag a few experts that can share their expertise.

Hey @Kevin-C @alyssamwilie @John any tips you can share with [@Amit\_95](https://community.hubspot.com/t5/user/viewprofilepage/user-id/64311)?

Thank you 🙂

Sharon

---

<div class="post-metadata">

**Author:** ![Kevin-C](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kevin-c/32/34570_2.png) [@Kevin-C](https://community.hubspot.com/u/Kevin-C)\
**Post date:** [September 8, 2020, 3:00pm UTC](https://community.hubspot.com/t/comparing-two-arrays-checking-for-matching-values/25055/3 "2020-09-08T15:00:53Z")

</div>

Hey [@Amit\_95](https://community.hubspot.com/t5/user/viewprofilepage/user-id/64311)

Have you tried “intersect”?

Using that filter it should return a dict with the matching objects.

`{{ topics|intersect(all_tags) }}`
