title: Proper way to iterate (foreach) with separator
body: <p>The foreach construct below works just fine if the items returned are more than one. However, if there is only one item displayed the separator | is still being retained.</p>
  
  <p>What's wrong with my code below?</p>
  
  <pre><code>&lt;?php 
  foreach ($array-&gt;items as $item) {
         $len = count($item);
              if ($i &lt; $len) {    
                 print '&lt;a href="' . $item-&gt;link . '"&gt;' . $item-&gt;title . '&lt;/a&gt;' . ' | ';
              }
  
              else {  
                 print '&lt;a href="' . $item-&gt;link . '"&gt;' . $item-&gt;title . '&lt;/a&gt;';
              }
          $i++;               
  }
  ?&gt;
  </code></pre>