<?xml version="1.0" encoding="UTF-8"?>    <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
      <channel>
        <title>Trim last item?</title>
        <link>https://interactivetools.com/forum/forum-posts.php?Trim-last-item-80302</link>
        <description></description>
        <pubDate>Fri, 06 Mar 2026 13:22:08 -0800</pubDate>
        <language>en-us</language>
        <atom:link href="https://interactivetools.com/forum/forum-posts.php?rss=1&amp;Trim-last-item-80302" rel="self" type="application/rss+xml" />

                <item>
          <title>Trim last item?</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2237742#post2237742</link>
          <description><![CDATA[<p>Hey Daryl - that worked thanks!  I changed <span>showme($imageAndCaptionString); to <span>echo($imageAndCaptionString);</span></span></p>]]></description>
          <pubDate>Thu, 19 Nov 2015 13:32:04 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2237742#post2237742</guid>
        </item>
                <item>
          <title>Trim last item?</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2237741#post2237741</link>
          <description><![CDATA[<p>Hi Tim,</p>
<p>Another way to do it is to check if the current array is the last item. If not, then add a comma.</p>
<p>For example:</p>
<p><code>$lastUploadRecord      = end($home_pageRecord['hero_image']); // get the last record<br />$imageAndCaptionString = '';<br />foreach ($home_pageRecord['hero_image'] as $index =&gt; $upload){<br />  $imageAndCaptionString .= '{img: "'.htmlencode($upload['urlPath']).'", caption: "'.htmlencode($upload['info1']).'"}';<br />  if ($upload['num'] != $lastUploadRecord['num']){<br />    $imageAndCaptionString .= ','; // add comma if this is not the last upload record<br />  }<br />}<br />showme($imageAndCaptionString);</code></p>
<p>Let me know if that works for you.</p>
<p>Thanks,</p>]]></description>
          <pubDate>Thu, 19 Nov 2015 13:22:28 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2237741#post2237741</guid>
        </item>
                <item>
          <title>Trim last item?</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2237740#post2237740</link>
          <description><![CDATA[<p>With the version json?<br /><br />Can you state that there is on line 161?</p>
<p>Thanks!</p>]]></description>
          <pubDate>Thu, 19 Nov 2015 02:00:03 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2237740#post2237740</guid>
        </item>
                <item>
          <title>Trim last item?</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2237739#post2237739</link>
          <description><![CDATA[<p>Hey Djulia.</p>
<p>I appreciate your help!</p>
<p>I am now getting the error: Notice: Array to string conversion in /home/thelakes/public_html/index.php on line 161Array];</p>
<p>If it helps, the complete code that I require is as below, and I'm trying to produce the highlighted.</p>
<blockquote>
<p>&lt;script&gt;</p>
<p>var items = [<br /><span style="color:#ff0000;">{ img: "image1.jpg", caption: "This is the first caption."}, </span><br /><span style="color:#ff0000;">{ img: "image2.jpg", caption: "This is the second caption."}</span> <br />];</p>
<p><span>var</span> images <span>=</span> $.map(items, <span>function</span>(<span>i</span>) { <span>return</span> i.img; });</p>
<p>$.backstretch(images); <br />$(<span>window</span>).on(<span><span>"</span>backstretch.show<span>"</span></span>, <span>function</span>(<span>e</span>, <span>instance</span>) { <br /><span>var</span> newCaption <span>=</span> items[instance.<span>index</span>].<span>caption</span>; <br />$(<span><span>"</span>.caption<span>"</span></span>).<span>text</span>( newCaption );<br /> });</p>
<p>&lt;/script&gt;</p>
</blockquote>

]]></description>
          <pubDate>Thu, 19 Nov 2015 01:44:21 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2237739#post2237739</guid>
        </item>
                <item>
          <title>Trim last item?</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2237738#post2237738</link>
          <description><![CDATA[<p>I corrected my proposal.</p>
<p><a href="http://www.interactivetools.com/forum/forum-posts.php?postNum=2237734#post2237734" rel="nofollow">http://www.interactivetools.com/forum/forum-posts.php?postNum=2237734#post2237734</a></p>]]></description>
          <pubDate>Thu, 19 Nov 2015 01:30:45 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2237738#post2237738</guid>
        </item>
                <item>
          <title>Trim last item?</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2237737#post2237737</link>
          <description><![CDATA[<p>Oops! I am not really awaked!</p>
<p>I have the feeling which you wish to obtain from the data encoded in json.<br /><br />Can you test this?</p>
<p>&lt;?php<br />    $str = array();<br />    foreach ($home_pageRecord['hero_image'] as $index =&gt; $upload) {<br />        $str[] = '{img: '. htmlencode($upload['urlPath']) .', caption: '. htmlencode($upload['info1']). '}';<br />    }</p>
<p>    //echo json_encode($str, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE), "\n\n";<br />    echo json_encode($str), "\n\n";<br />?&gt;</p>]]></description>
          <pubDate>Thu, 19 Nov 2015 01:15:57 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2237737#post2237737</guid>
        </item>
                <item>
          <title>Trim last item?</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2237735#post2237735</link>
          <description><![CDATA[<p>Thanks Djulia.</p>
<p>I think you missed a bracket "<span style="color:#ff0000;">(</span>", but it's also trimming both commas, not just the last one?</p>
<blockquote>
<p>&lt;?php </p>
<p>foreach ($home_pageRecord['hero_image'] as $index =&gt; $upload) {<br /> echo rtrim('{img: '. htmlencode($upload['urlPath']) .', caption: '. htmlencode<span style="color:#ff0000;">(</span>$upload['info1']). '},', ',');<br /> }<br />?&gt;</p>
</blockquote>
<p>is returning</p>
<blockquote>
<p><span>{img: /~thelakes/cmsb/uploads/s1.jpg, caption: This is slide 1}{img: /~thelakes/cmsb/uploads/s2.jpg, caption: heres another slide}];</span></p>
</blockquote>
<p><span>and needs to return</span></p>
<blockquote>
<p><span><span>{img: /~thelakes/cmsb/uploads/s1.jpg, caption: This is slide 1}<span style="color:#ff0000;">,</span>{img: /~thelakes/cmsb/uploads/s2.jpg, caption: heres another slide}];</span></span></p>
</blockquote>



]]></description>
          <pubDate>Thu, 19 Nov 2015 00:39:22 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2237735#post2237735</guid>
        </item>
                <item>
          <title>Trim last item?</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2237734#post2237734</link>
          <description><![CDATA[<p>Hi Tim,</p>
<p><span><span>Try this :<br /></span></span></p>
<p>&lt;?php<br />    $str = array();<br />    foreach ($home_pageRecord['hero_image'] as $index =&gt; $upload) {<br />        $str[] = '{img: '. htmlencode($upload['urlPath']) .', caption: '. htmlencode($upload['info1']). '}';<br />    } echo implode(",", $str), "\n\n";<br />?&gt;</p>
<p>Thanks!</p>
<p>Djulia</p>]]></description>
          <pubDate>Wed, 18 Nov 2015 23:39:42 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2237734#post2237734</guid>
        </item>
                <item>
          <title>Trim last item?</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2237733#post2237733</link>
          <description><![CDATA[<p>Hi All.</p>
<p>I've got a bunch of images, each with a caption, from which I can do the following:</p>
<blockquote>
<p>&lt;?php foreach ($home_pageRecord['hero_image'] as $index =&gt; $upload): ?&gt;<br /> { img: '&lt;?php echo htmlencode($upload['urlPath']) ?&gt;', caption: "&lt;?php echo $upload['info1'] ?&gt;"},<br />&lt;?php endforeach ?&gt;</p>
</blockquote>
<p>However, I need to trim the final item to remove the comma?</p>


]]></description>
          <pubDate>Wed, 18 Nov 2015 22:56:45 -0800</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2237733#post2237733</guid>
        </item>
              </channel>
    </rss>
  