<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Comparing two arrays, checking for matching values in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Comparing-two-arrays-checking-for-matching-values/m-p/367514#M18465</link>
    <description>&lt;P&gt;I have a repeater field which allows user to add text.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've created an array which stores all these repeater values into an array called topics.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{% set topics = [] %}

&amp;lt;!-- append topics from repeater to array --&amp;gt;
{% for item in module.add_topics.topics %}
  {% set topic_option = item|striptags %}
  {% do topics.append( topic_option ) %}
{% endfor %}

&amp;lt;!-- dumping data 
{{ topics }}

[Data, Accounting, Insight]
--&amp;gt; &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above is basically a predefined list. I now want to compare values in the above array to all blog tags that exist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Demo:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{% set all_tags = blog_topics('default' , 250) %}

{{ all_tags }}

&amp;lt;!-- above prints: [Accounting, Press, Data] --&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So from the above two arrays, Data and Accounting are in both. I now want to create another array which has these matching values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I go about this?&lt;/P&gt;</description>
    <pubDate>Fri, 04 Sep 2020 10:07:43 GMT</pubDate>
    <dc:creator>Amit_95</dc:creator>
    <dc:date>2020-09-04T10:07:43Z</dc:date>
    <item>
      <title>Comparing two arrays, checking for matching values</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Comparing-two-arrays-checking-for-matching-values/m-p/367514#M18465</link>
      <description>&lt;P&gt;I have a repeater field which allows user to add text.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've created an array which stores all these repeater values into an array called topics.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{% set topics = [] %}

&amp;lt;!-- append topics from repeater to array --&amp;gt;
{% for item in module.add_topics.topics %}
  {% set topic_option = item|striptags %}
  {% do topics.append( topic_option ) %}
{% endfor %}

&amp;lt;!-- dumping data 
{{ topics }}

[Data, Accounting, Insight]
--&amp;gt; &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above is basically a predefined list. I now want to compare values in the above array to all blog tags that exist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Demo:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{% set all_tags = blog_topics('default' , 250) %}

{{ all_tags }}

&amp;lt;!-- above prints: [Accounting, Press, Data] --&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So from the above two arrays, Data and Accounting are in both. I now want to create another array which has these matching values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I go about this?&lt;/P&gt;</description>
      <pubDate>Fri, 04 Sep 2020 10:07:43 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Comparing-two-arrays-checking-for-matching-values/m-p/367514#M18465</guid>
      <dc:creator>Amit_95</dc:creator>
      <dc:date>2020-09-04T10:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two arrays, checking for matching values</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Comparing-two-arrays-checking-for-matching-values/m-p/368002#M18485</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/64311"&gt;@Amit_95&lt;/a&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt; Thank you for sharing this. I'll tag a few experts that can share their expertise. &amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/73772"&gt;@Kevin-C&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/91608"&gt;@alyssamwilie&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/4468"&gt;@John&lt;/a&gt;&amp;nbsp;&amp;nbsp;any tips you can share with&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/64311"&gt;@Amit_95&lt;/a&gt;?&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Sharon&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Sep 2020 09:55:50 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Comparing-two-arrays-checking-for-matching-values/m-p/368002#M18485</guid>
      <dc:creator>sharonlicari</dc:creator>
      <dc:date>2020-09-07T09:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two arrays, checking for matching values</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Comparing-two-arrays-checking-for-matching-values/m-p/368445#M18508</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/64311"&gt;@Amit_95&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you tried "intersect"?&lt;/P&gt;
&lt;P&gt;Using that filter it should return a dict with the matching objects.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{{ topics|intersect(all_tags) }}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2020 15:54:11 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Comparing-two-arrays-checking-for-matching-values/m-p/368445#M18508</guid>
      <dc:creator>Kevin-C</dc:creator>
      <dc:date>2020-09-08T15:54:11Z</dc:date>
    </item>
  </channel>
</rss>

