<?xml version="1.0" encoding="UTF-8"?>    <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
      <channel>
        <title>Ask for help about comma to every item but last one</title>
        <link>https://interactivetools.com/forum/forum-posts.php?Ask-for-help-about-comma-to-every-item-but-last-one-82525</link>
        <description></description>
        <pubDate>Mon, 20 Apr 2026 05:05:28 -0700</pubDate>
        <language>en-us</language>
        <atom:link href="https://interactivetools.com/forum/forum-posts.php?rss=1&amp;Ask-for-help-about-comma-to-every-item-but-last-one-82525" rel="self" type="application/rss+xml" />

                <item>
          <title>Ask for help about comma to every item but last one</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2245920#post2245920</link>
          <description><![CDATA[<p>You can also use the trim function on a string and supply a comma as the second parameter:</p>
<pre class="language-markup"><code>trim("test, test1, test2,", ",") 

will yield:

test, test1, test2</code></pre>
<p>You can pass multiple characters in the second parameter and all will be remove both leading and trailing.</p>]]></description>
          <pubDate>Sun, 17 Apr 2022 11:38:47 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2245920#post2245920</guid>
        </item>
                <item>
          <title>Ask for help about comma to every item but last one</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2245917#post2245917</link>
          <description><![CDATA[<p>Hello,</p>
<p>This is perfect.</p>
<p>Thank You</p>]]></description>
          <pubDate>Sat, 09 Apr 2022 03:16:14 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2245917#post2245917</guid>
        </item>
                <item>
          <title>Ask for help about comma to every item but last one</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2245916#post2245916</link>
          <description><![CDATA[<p>Hi Tom,</p>
<p>For this kind of loop, it looks like you'll want to echo the <span>$movie_catName variable, rather than using the implode function which is displaying all categories on every loop. I would then add a "count" variable to track which loop you're on, to check if you need to add a comma. Something like this should work:</span></p>
<pre class="language-php"><code>&lt;?php $movie_cat = array_combine($listing['movie_cat:values'], $listing['movie_cat:labels']); ?&gt;
&lt;?php $count = 0; ?&gt;
&lt;?php foreach ($movie_cat as $movie_catNum =&gt; $movie_catName): ?&gt;
&lt;?php
  if ($count++ &gt; 0) {
    echo ', ';
  }
?&gt;&lt;a href="listings.php?movie_cat=&lt;?php echo $movie_catNum;?&gt;"&gt;&lt;?php echo $movie_catName; ?&gt;&lt;/a&gt;
&lt;?php endforeach ?&gt;</code></pre>
<p>You can also check out Jerry's CMSB Cookbook for other examples and ideas!</p>
<p>Thanks,</p>]]></description>
          <pubDate>Fri, 08 Apr 2022 16:21:11 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2245916#post2245916</guid>
        </item>
                <item>
          <title>Ask for help about comma to every item but last one</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2245915#post2245915</link>
          <description><![CDATA[<p>Hi Tom,</p>
<p>There's a simple code example in my CMSB Cookbook that explains one method that drops the trailing comma in a series. It should point you in the right direction.</p>
<p><a href="http://www.thecmsbcookbook.com/recipedetail.php?REMOVE-THE-TRAILING-COMMA-AFTER-LAST-IMAGE-IN-A-SERIES-355" rel="nofollow">http://www.thecmsbcookbook.com/recipedetail.php?REMOVE-THE-TRAILING-COMMA-AFTER-LAST-IMAGE-IN-A-SERIES-355</a></p>
<p>You can get a 3 month trial subscription to the CMSB Cookbook using the link below.</p>
<p>Hope that helps,</p>
<p>Jerry Kornbluth</p>]]></description>
          <pubDate>Fri, 08 Apr 2022 13:10:51 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2245915#post2245915</guid>
        </item>
                <item>
          <title>Ask for help about comma to every item but last one</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2245914#post2245914</link>
          <description><![CDATA[<p>Hello,</p>
<p>Below is my code.</p>
<p>&lt;?php $movie_cat = array_combine($listing['movie_cat:values'], $listing['movie_cat:labels']); ?&gt;<br />&lt;?php foreach ($movie_cat as $movie_catNum =&gt; $movie_catName): ?&gt;<br />&lt;a href="listings.php?movie_cat=&lt;?php echo $movie_catNum;?&gt;"&gt;&lt;?php echo implode( ', ', $listing['movie_cat:labels'] ); ?&gt;&lt;/a&gt;<br />&lt;?php endforeach ?&gt;</p>
<p>What I intend to do is output TEST1, TEST2, TEST3 instead of Test1 Test2 Test3</p>
<p>However it returns</p>
<p>Test1,Test2,Test3 Test1,Test2,Test3 Test1,Test2,Test3</p>
<p>Could you please take a look on it.</p>
<p>Thank You</p>


]]></description>
          <pubDate>Fri, 08 Apr 2022 12:48:58 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2245914#post2245914</guid>
        </item>
              </channel>
    </rss>
  