<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to print 2d array</title><link>https://community.appian.com/discussions/f/rules/19956/how-to-print-2d-array</link><description>I want to print 2D array 
 a!localVariables( local!a:{{1,2}, {3,4},{6,7}}, a!forEach( items: local!a, expression: fv!item )) 
 This will give below result 
 1 2 3 4 6 7 
 But I want to print the result in below form 
 1,2 3,4 6,7</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to print 2d array</title><link>https://community.appian.com/thread/78023?ContentTypeID=1</link><pubDate>Fri, 20 Nov 2020 18:00:45 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ff0d4284-a252-49d2-8a4c-1034f00307b3</guid><dc:creator>ankitas0001</dc:creator><description>&lt;p&gt;Thanks Chirs&amp;nbsp;&lt;span&gt;for enhancing my knowledge.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to print 2d array</title><link>https://community.appian.com/thread/78022?ContentTypeID=1</link><pubDate>Fri, 20 Nov 2020 17:55:47 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c89bf4e6-a028-401c-a890-65b628d26a0b</guid><dc:creator>ankitas0001</dc:creator><description>&lt;p&gt;Thanks Scott&amp;nbsp;this helped me.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to print 2d array</title><link>https://community.appian.com/thread/78012?ContentTypeID=1</link><pubDate>Thu, 19 Nov 2020 20:55:32 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a4369d47-2bfa-47c4-9544-b6e80c462a78</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;We can nix the nested a!foreach() in the second example above as well:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;a!localVariables(
  local!a: {{1,2},{3,4},{6,7}},
  a!forEach(
    items: 1+enumerate(count(local!a)/2),
    expression: joinarray(index(local!a,{fv!item*2-1,fv!item*2},null),&amp;quot;,&amp;quot;)
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to print 2d array</title><link>https://community.appian.com/thread/78011?ContentTypeID=1</link><pubDate>Thu, 19 Nov 2020 20:51:51 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:95a5c6be-1c0c-4df1-ab2b-92e56ad04529</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;The issue here is that the array is being flattened and a!foreach() sees it as 6 items, vs 3 pairs of 2 items each.&amp;nbsp; I&amp;#39;m not sure if we can unflatten it directly within a primitive data type.&lt;/p&gt;
&lt;p&gt;Are you able to control the array, such as formatting it to key/value pairs? Such as:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;a!localVariables(
  local!a: {
    {value: {1,2}},
    {value: {3,4}},
    {value: {6,7}}
  },
  a!forEach(
    items: local!a,
    expression: joinarray(fv!item.value,&amp;quot;,&amp;quot;)
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Or, do we know that this data will &lt;em&gt;always&lt;/em&gt; be an array of 2-valued nested arrays?&amp;nbsp; Such as:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;a!localVariables(
  local!a: {{1,2},{3,4},{6,7}},
  a!forEach(
    items: 1+enumerate(count(local!a)/2),
    expression: joinarray(
      a!foreach(
        items: {fv!item*2-1,fv!item*2},
        expression: index(local!a,fv!item,null)
      ),
      &amp;quot;,&amp;quot;
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to print 2d array</title><link>https://community.appian.com/thread/78010?ContentTypeID=1</link><pubDate>Thu, 19 Nov 2020 20:25:06 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d5f70b59-aeb4-4c30-896b-c12e7cf60a62</guid><dc:creator>Scott Milton</dc:creator><description>&lt;p&gt;In your example above the expression your a!foreach will run on each iteration, is just the value e.g., {1,2}, so that pair/array will be displayed however is appropriate for that type of value.&amp;nbsp; If you have some specific expression rule or function that displays&amp;nbsp;that type of value how you want, then you should use that instead of just the value.&amp;nbsp; For example, instead of just expression:fv!item, use &lt;span&gt;expression:&lt;/span&gt;joinArray(fv!item, &amp;quot;,&amp;quot;).&amp;nbsp; &amp;nbsp;&lt;a href="https://docs.appian.com/suite/help/20.3/fnc_array_joinarray.html"&gt;docs.appian.com/.../fnc_array_joinarray.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>